Documentation
¶
Overview ¶
Package notesclient is the runtime-side client to the daemon's agent_notes table. Mirrors the legacy pkg/notes.Store API so the tool layer and PrepareStep renderer can swap stores for clients without changing call sites.
Configuration mirrors pkg/jobsclient: OTTERSD_URL + OTTERS_AGENT_TOKEN from the spawn env. The daemon scopes every call to the JWT's agent_ref, so the client never needs to know its own UUID — empty ref on the wire makes the daemon read it from the bearer token.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) Delete(ctx context.Context, key string) error
- func (c *Client) Get(ctx context.Context, key string) (Note, error)
- func (c *Client) List(ctx context.Context) ([]Note, error)
- func (c *Client) ListInContext(ctx context.Context) ([]Note, error)
- func (c *Client) Save(ctx context.Context, key, content string, maxBytes, maxCount int) error
- func (c *Client) SetInContext(ctx context.Context, key string, inContext bool) error
- type Config
- type Fake
- func (f *Fake) Delete(_ context.Context, key string) error
- func (f *Fake) Get(_ context.Context, key string) (notes.Note, error)
- func (f *Fake) List(_ context.Context) ([]notes.Note, error)
- func (f *Fake) ListInContext(_ context.Context) ([]notes.Note, error)
- func (f *Fake) Save(_ context.Context, key, content string, maxBytes, maxCount int) error
- func (f *Fake) SetInContext(_ context.Context, key string, inContext bool) error
- type Note
- type Store
Constants ¶
const ( EnvDaemonURL = "OTTERSD_URL" //nolint:gosec // G101: env var name, not a credential value EnvAgentToken = "OTTERS_AGENT_TOKEN" )
Variables ¶
var ( ErrInvalidKey = errors.New("invalid note key") ErrNoteTooLarge = errors.New("note content exceeds size cap") ErrTooManyNotes = errors.New("note count would exceed cap") ErrNoteNotFound = errors.New("note not found") ErrNotConfigured = errors.New( "notesclient: OTTERSD_URL and OTTERS_AGENT_TOKEN must both be set", ) )
Sentinel errors. Returned with %w-wrapping so callers can errors.Is to render meaningful messages.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Delete ¶
Delete removes a note by key. Idempotent — no error when the key was never present.
func (*Client) List ¶
List mirrors notes.Store.List — every note ordered by most-recently-updated first. Body is omitted to keep payloads small; callers fetch the body via Get.
func (*Client) ListInContext ¶
ListInContext mirrors notes.Store.ListInContext.
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is an in-memory implementation of the Store / NotesProvider surfaces used by the runtime's tool layer and PrepareStep callback. Test-only; production code uses *Client over gRPC.
type Note ¶
Note re-exports notes.Note so callers can write notesclient.Note without importing both packages. Same in-memory shape; same renderers; only the storage moved.
type Store ¶
type Store interface {
List(ctx context.Context) ([]notes.Note, error)
ListInContext(ctx context.Context) ([]notes.Note, error)
Get(ctx context.Context, key string) (notes.Note, error)
Save(ctx context.Context, key, content string, maxBytes, maxCount int) error
Delete(ctx context.Context, key string) error
SetInContext(ctx context.Context, key string, inContext bool) error
}
Store is the interface BuildNotesTools / BuildNotesPrepareStep need from a notes backend. *Client satisfies it in production; *Fake satisfies it in tests.