Help us shape the future of Go! Take the 2026 Go Developer Survey

ports

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ports defines the document, indexing and codec contracts used by the migrated notes.

Index

Constants

This section is empty.

Variables

View Source
var ErrHabitNotFound = errors.New("habit not found")
View Source
var ErrJournalAlreadyExists = errors.New("journal already exists")
View Source
var ErrNoteNotFound = errors.New("note not found")
View Source
var ErrPersonNotFound = errors.New("person not found")

Functions

This section is empty.

Types

type BookmarkEncoder added in v0.3.0

type BookmarkEncoder interface {
	Encode(*bookmarks.Bookmark) ([]byte, error)
}

type BookmarkRepository added in v0.3.0

type BookmarkRepository interface {
	Save(context.Context, *bookmarks.Bookmark) error
}

type HabitCodec added in v0.3.0

type HabitCodec interface {
	Encode(*habits.Habit) ([]byte, error)
	Decode([]byte) (*habits.Habit, error)
}

HabitCodec translates between a habit and its persisted document.

type HabitRepository added in v0.3.0

type HabitRepository interface {
	Save(context.Context, *habits.Habit) error
	ByID(context.Context, uuid.UUID) (*habits.Habit, error)
}

HabitRepository stores habit definitions.

type IDGenerator

type IDGenerator interface{ Generate() uuid.UUID }

IDGenerator generates entity identifiers.

type InboxEncoder added in v0.3.0

type InboxEncoder interface {
	Encode(*inbox.Inbox) ([]byte, error)
}

type InboxRepository added in v0.3.0

type InboxRepository interface {
	Save(context.Context, *inbox.Inbox) error
}

type Index added in v0.3.0

type Index interface {
	UpsertPage(context.Context, *pages.Page, string) error
	UpsertJournal(context.Context, *journals.Journal, string) error
	JournalExists(context.Context, calendar.Date) (bool, error)
	UpsertBookmark(context.Context, *bookmarks.Bookmark, string) error
	UpsertInbox(context.Context, *inbox.Inbox, string) error
	UpsertHabit(context.Context, *habits.Habit, string) error
	UpsertPerson(context.Context, *persons.Person, string) error
}

Index maintains searchable projections; documents remain the source of truth.

type IndexRebuilder added in v0.3.0

type IndexRebuilder interface {
	Rebuild(context.Context, func(Index) error) error
}

IndexRebuilder replaces all projections atomically. The supplied index is scoped to populate; it must not be retained after the callback returns.

type JournalEncoder added in v0.3.0

type JournalEncoder interface {
	Encode(*journals.Journal) ([]byte, error)
}

type JournalRepository added in v0.3.0

type JournalRepository interface {
	Save(context.Context, *journals.Journal) error
}

type Note added in v0.3.0

type Note struct {
	ID      uuid.UUID
	Content []byte
	Path    string
}

Note is a stored document; its content format is determined by its codec.

type NoteFilter added in v0.3.0

type NoteFilter struct {
	Type   string
	Tag    string
	Limit  int
	Offset int
}

NoteFilter selects indexed notes. Empty type and tag match all notes.

type NoteFinder added in v0.3.0

type NoteFinder interface {
	FindNotes(context.Context, NoteFilter) ([]NoteSummary, error)
}

NoteFinder reads summaries without loading or decoding note documents.

type NoteIndexDeleter added in v0.3.0

type NoteIndexDeleter interface {
	Delete(context.Context, uuid.UUID) error
}

NoteIndexDeleter removes a note projection and its associated rows. Deleting an absent note is successful.

type NoteKind added in v0.3.0

type NoteKind string

NoteKind identifies the persisted document format, not an entity property.

const (
	NoteKindPage     NoteKind = "page"
	NoteKindJournal  NoteKind = "journal"
	NoteKindHabit    NoteKind = "habit"
	NoteKindPerson   NoteKind = "person"
	NoteKindBookmark NoteKind = "bookmark"
	NoteKindInbox    NoteKind = "inbox"
)

func (NoteKind) String added in v0.3.0

func (kind NoteKind) String() string

type NoteProjector added in v0.3.0

type NoteProjector interface {
	Project(context.Context, Note, Index) error
}

NoteProjector decodes a document and writes its validated projection.

type NoteScanner added in v0.3.0

type NoteScanner interface {
	Scan(context.Context, func(Note) error) error
}

NoteScanner visits documents independently of the current index.

type NoteStore added in v0.3.0

type NoteStore interface {
	Put(context.Context, Note) (string, error)
	Get(context.Context, uuid.UUID) (Note, error)
	Delete(context.Context, uuid.UUID) error
}

NoteStore persists documents independently of their domain model or format. Put returns the actual stored path; Get includes that path in the note.

type NoteSummary added in v0.3.0

type NoteSummary struct {
	ID        uuid.UUID
	Type      string
	Label     string
	Tags      []string
	UpdatedAt time.Time
}

NoteSummary is a read projection, independent of the note's domain entity.

type PageEncoder added in v0.3.0

type PageEncoder interface {
	Encode(*pages.Page) ([]byte, error)
}

type PageRepository added in v0.3.0

type PageRepository interface {
	Save(context.Context, *pages.Page) error
}

type PersonCodec added in v0.3.0

type PersonCodec interface {
	Encode(*persons.Person) ([]byte, error)
	Decode([]byte) (*persons.Person, error)
}

type PersonRepository added in v0.3.0

type PersonRepository interface {
	Save(context.Context, *persons.Person) error
	ByID(context.Context, uuid.UUID) (*persons.Person, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL