Documentation
¶
Overview ¶
Package client is the reference client for the dcode protocol.
It is the first consumer of the contract. If the API feels awkward here, the protocol is what needs fixing, not this package.
It holds no session state: only a read position, which is what lets a client die and rejoin without the session noticing.
Index ¶
- type Client
- func (c *Client) CreateSession(ctx context.Context, req protocol.CreateSessionRequest) (protocol.Session, error)
- func (c *Client) DeleteSession(ctx context.Context, id string) error
- func (c *Client) GetSession(ctx context.Context, id string) (protocol.Session, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) Interrupt(ctx context.Context, id string) error
- func (c *Client) ListSessions(ctx context.Context) ([]protocol.Session, error)
- func (c *Client) RenameSession(ctx context.Context, id, name string) error
- func (c *Client) Resolve(ctx context.Context, id, approvalID string, d protocol.ApprovalDecision) error
- func (c *Client) Steer(ctx context.Context, id, text string) error
- func (c *Client) Submit(ctx context.Context, id, text string, images ...protocol.TurnImage) error
- func (c *Client) Subscribe(ctx context.Context, id string, from uint64) (<-chan protocol.Event, <-chan error)
- func (c *Client) Undo(ctx context.Context, id string) (protocol.UndoResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a dcode daemon over a Unix socket.
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, req protocol.CreateSessionRequest) (protocol.Session, error)
CreateSession opens a session.
func (*Client) DeleteSession ¶
DeleteSession closes a session.
func (*Client) GetSession ¶
GetSession returns one session.
func (*Client) ListSessions ¶
ListSessions returns live sessions.
func (*Client) RenameSession ¶ added in v0.2.0
RenameSession names a conversation, live or not.
An empty name restores the title derived from the first question. That is the way back rather than a second call for undoing: one operation with a meaningful zero value is one thing to get right.
func (*Client) Steer ¶
Steer hands a running turn something the person said, without ending it.
Refused when no turn is running: a correction to a turn that already finished is a new message, and quietly turning it into one would let the person believe an urgent instruction landed when it never did.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, id string, from uint64) (<-chan protocol.Event, <-chan error)
Subscribe streams events from `from`, reconnecting on its own.
Reconnection resumes at the last sequence seen plus one, which is why the read position is the only state a client keeps. Reconnecting therefore behaves exactly like connecting for the first time.