Documentation
¶
Overview ¶
Package client implements the ARCP client surface: dial, submit, observe, cancel, subscribe.
Index ¶
- type Client
- func (c *Client) Ack(ctx context.Context, seq uint64) error
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) Features() []string
- func (c *Client) HasFeature(name string) bool
- func (c *Client) ListJobs(ctx context.Context, req ListJobsRequest) (*JobList, error)
- func (c *Client) SessionID() string
- func (c *Client) Submit(ctx context.Context, req SubmitRequest) (*JobHandle, error)
- func (c *Client) Subscribe(ctx context.Context, jobID string, opts SubscribeOptions) (*Subscription, error)
- func (c *Client) Welcome() *messages.SessionWelcome
- type JobHandle
- func (h *JobHandle) Accepted() *messages.JobAccepted
- func (h *JobHandle) Agent() string
- func (h *JobHandle) Cancel(ctx context.Context, reason string) error
- func (h *JobHandle) Chunks() <-chan messages.ResultChunkBody
- func (h *JobHandle) CollectChunks(ctx context.Context) ([]byte, error)
- func (h *JobHandle) Done() <-chan struct{}
- func (h *JobHandle) Err() error
- func (h *JobHandle) Events() <-chan messages.JobEvent
- func (h *JobHandle) ID() string
- func (h *JobHandle) Result() *messages.JobResult
- func (h *JobHandle) Wait(ctx context.Context) (*messages.JobResult, error)
- type JobList
- type ListJobsRequest
- type Options
- type SubmitRequest
- type SubscribeOptions
- type Subscription
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 is the client-side view of one ARCP session. Construct with Connect.
func Connect ¶
Connect performs a session.hello / session.welcome handshake on t and returns a connected Client.
func (*Client) HasFeature ¶
HasFeature reports whether name was negotiated.
func (*Client) Submit ¶
Submit emits a job.submit envelope and returns a handle. The returned handle has a pre-allocated job id; the runtime echoes it back in job.accepted, at which point the handle is "accepted".
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, jobID string, opts SubscribeOptions) (*Subscription, error)
Subscribe attaches the current session to jobID. The runtime validates principal authority before returning a subscription handle.
func (*Client) Welcome ¶
func (c *Client) Welcome() *messages.SessionWelcome
Welcome returns the welcome payload received from the runtime.
type JobHandle ¶
type JobHandle struct {
// contains filtered or unexported fields
}
JobHandle is the client-side view of one submitted job.
func (*JobHandle) Accepted ¶
func (h *JobHandle) Accepted() *messages.JobAccepted
Accepted returns the job.accepted payload.
func (*JobHandle) Chunks ¶
func (h *JobHandle) Chunks() <-chan messages.ResultChunkBody
Chunks returns the result_chunk-only event channel. Closed when the job terminates.
func (*JobHandle) CollectChunks ¶
CollectChunks reads chunks until the stream terminates and returns the assembled bytes by result_id. Returns an error if encodings are mixed or chunks arrive out of order.
func (*JobHandle) Done ¶
func (h *JobHandle) Done() <-chan struct{}
Done returns a channel closed when the job reaches a terminal state.
func (*JobHandle) Events ¶
Events returns the live event channel. It is closed when the job reaches a terminal state.
type ListJobsRequest ¶
type ListJobsRequest struct {
Filter messages.ListJobsFilter
Limit int
Cursor string
}
ListJobsRequest is the input to Client.ListJobs.
type Options ¶
type Options struct {
// ClientName advertised in session.hello.client.name.
ClientName string
// ClientVersion advertised in session.hello.client.version.
ClientVersion string
// Token is the bearer token passed via session.hello.auth.token.
Token string
// Features overrides the advertised feature list. Empty uses the
// SDK default set.
Features []string
// Logger receives client diagnostics. nil uses slog.Default().
Logger *slog.Logger
// AutoAck coalesces session.ack emission to one every Window
// events processed (zero disables auto-ack).
AutoAckWindow uint64
// AutoAckInterval bounds how long auto-ack waits between sends.
AutoAckInterval time.Duration
}
Options configures a Client.
type SubmitRequest ¶
type SubmitRequest struct {
Agent string
Input any
LeaseRequest arcp.Lease
LeaseConstraints *messages.LeaseConstraints
IdempotencyKey string
MaxRuntimeSec int
TraceID string
}
SubmitRequest is the input to Client.Submit.
type SubscribeOptions ¶
SubscribeOptions configures a Client.Subscribe call.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is the client-side view of a job.subscribe attachment.
func (*Subscription) Close ¶
func (s *Subscription) Close(ctx context.Context) error
Close detaches the subscription.
func (*Subscription) Done ¶
func (s *Subscription) Done() <-chan struct{}
Done returns a channel closed when the subscription ends.
func (*Subscription) Err ¶
func (s *Subscription) Err() error
Err returns the terminal subscription error, if any.
func (*Subscription) Events ¶
func (s *Subscription) Events() <-chan messages.JobEvent
Events returns the live event channel.
func (*Subscription) JobID ¶
func (s *Subscription) JobID() string
JobID returns the subscribed job id.