client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client implements the ARCP client surface: dial, submit, observe, cancel, subscribe.

Index

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

func Connect(ctx context.Context, t transport.Transport, opts Options) (*Client, error)

Connect performs a session.hello / session.welcome handshake on t and returns a connected Client.

func (*Client) Ack

func (c *Client) Ack(ctx context.Context, seq uint64) error

Ack emits a session.ack with last_processed_seq.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close terminates the session.

func (*Client) Features

func (c *Client) Features() []string

Features returns the effective negotiated feature set.

func (*Client) HasFeature

func (c *Client) HasFeature(name string) bool

HasFeature reports whether name was negotiated.

func (*Client) ListJobs

func (c *Client) ListJobs(ctx context.Context, req ListJobsRequest) (*JobList, error)

ListJobs requests a read-only inventory.

func (*Client) SessionID

func (c *Client) SessionID() string

SessionID returns the negotiated session identifier.

func (*Client) Submit

func (c *Client) Submit(ctx context.Context, req SubmitRequest) (*JobHandle, error)

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) Agent

func (h *JobHandle) Agent() string

Agent returns the requested agent identifier.

func (*JobHandle) Cancel

func (h *JobHandle) Cancel(ctx context.Context, reason string) error

Cancel sends job.cancel.

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

func (h *JobHandle) CollectChunks(ctx context.Context) ([]byte, error)

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) Err

func (h *JobHandle) Err() error

Err returns the terminal error, if any.

func (*JobHandle) Events

func (h *JobHandle) Events() <-chan messages.JobEvent

Events returns the live event channel. It is closed when the job reaches a terminal state.

func (*JobHandle) ID

func (h *JobHandle) ID() string

ID returns the runtime-assigned job id once accepted, else "".

func (*JobHandle) Result

func (h *JobHandle) Result() *messages.JobResult

Result returns the terminal job.result payload, if any.

func (*JobHandle) Wait

func (h *JobHandle) Wait(ctx context.Context) (*messages.JobResult, error)

Wait blocks until the job terminates or ctx is cancelled.

type JobList

type JobList struct {
	Jobs       []messages.JobInfo
	NextCursor string
}

JobList is the response.

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

type SubscribeOptions struct {
	FromEventSeq uint64
	History      bool
}

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.

Jump to

Keyboard shortcuts

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