Documentation
¶
Overview ¶
Package brokerapi defines the local realtime registry protocol and Go client.
Index ¶
- Constants
- Variables
- func IsUnavailable(err error) bool
- func SocketPath(storePath string) string
- type Client
- func (c *Client) GC(ctx context.Context, deleteAfter time.Duration) (registry.GCResult, error)
- func (c *Client) Get(ctx context.Context, id string) (registry.Session, error)
- func (c *Client) List(ctx context.Context, filter registry.Filter) ([]registry.Session, error)
- func (c *Client) Observe(ctx context.Context, observation registry.Observation) (registry.Session, error)
- func (c *Client) ObserveBatch(ctx context.Context, observations []registry.Observation) ([]registry.Session, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) SocketPath() string
- func (c *Client) Subscribe(ctx context.Context, filter registry.Filter) (*Subscription, error)
- func (c *Client) Summary(ctx context.Context, filter registry.Filter) ([]registry.Summary, error)
- type Error
- type RemoteError
- type Request
- type Response
- type Store
- func (s *Store) Client() *Client
- func (s *Store) GC(ctx context.Context, deleteAfter time.Duration) (registry.GCResult, error)
- func (s *Store) Get(ctx context.Context, id string) (registry.Session, error)
- func (s *Store) List(ctx context.Context, filter registry.Filter) ([]registry.Session, error)
- func (s *Store) Observe(ctx context.Context, observation registry.Observation) (registry.Session, error)
- func (s *Store) ObserveBatch(ctx context.Context, observations []registry.Observation) ([]registry.Session, error)
- func (s *Store) SummaryByTmuxSession(ctx context.Context, filter registry.Filter) ([]registry.Summary, error)
- func (s *Store) SummaryByTmuxSessionWithOptions(ctx context.Context, options registry.SummaryOptions) ([]registry.Summary, error)
- type Subscription
Constants ¶
const ( // ProtocolVersion is the current newline-delimited JSON protocol version. ProtocolVersion = 1 MethodPing = "ping" MethodObserve = "observe" MethodObserveBatch = "observe_batch" MethodList = "list" MethodGet = "get" MethodSummary = "summary" MethodGC = "gc" MethodSubscribe = "subscribe" )
const SocketPathEnv = "AHT_SOCKET"
SocketPathEnv overrides the broker socket used by clients and integrations.
Variables ¶
var ( ErrUnavailable = errors.New("aht broker unavailable") // ErrProtocol means the broker returned an invalid or incompatible frame. ErrProtocol = errors.New("aht broker protocol error") )
Functions ¶
func IsUnavailable ¶
IsUnavailable reports whether err means no broker accepted the connection.
func SocketPath ¶
SocketPath returns the local socket for one registry snapshot path.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client sends registry operations to one local broker.
func (*Client) Observe ¶
func (c *Client) Observe(ctx context.Context, observation registry.Observation) (registry.Session, error)
Observe records one observation in the broker.
func (*Client) ObserveBatch ¶
func (c *Client) ObserveBatch( ctx context.Context, observations []registry.Observation, ) ([]registry.Session, error)
ObserveBatch records a group of observations atomically in the broker.
func (*Client) SocketPath ¶
SocketPath returns the exact endpoint used by the client.
type RemoteError ¶
RemoteError is an operation error returned by the broker.
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
type Request ¶
type Request struct {
Version int `json:"version"`
ID string `json:"id,omitempty"`
Method string `json:"method"`
Observation *registry.Observation `json:"observation,omitempty"`
Observations []registry.Observation `json:"observations,omitempty"`
Filter registry.Filter `json:"filter,omitzero"`
SessionID string `json:"session_id,omitempty"`
DeleteAfter time.Duration `json:"delete_after,omitempty"`
}
Request is one broker RPC. Subscribe keeps the connection open after the initial response and streams Snapshot frames.
type Response ¶
type Response struct {
Version int `json:"version"`
ID string `json:"id,omitempty"`
Type string `json:"type"`
Error *Error `json:"error,omitempty"`
Session *registry.Session `json:"session,omitempty"`
Sessions []registry.Session `json:"sessions,omitempty"`
Summaries []registry.Summary `json:"summaries,omitempty"`
Snapshot *registry.StateSnapshot `json:"snapshot,omitempty"`
GC *registry.GCResult `json:"gc,omitempty"`
Now time.Time `json:"now,omitzero"`
}
Response is one broker result or subscription frame.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store routes operations through the realtime broker and falls back to the durable snapshot when the broker is offline. The fallback keeps one-shot CLI use functional; a running broker remains the authoritative hot path.
func (*Store) ObserveBatch ¶
func (*Store) SummaryByTmuxSession ¶
func (*Store) SummaryByTmuxSessionWithOptions ¶
type Subscription ¶
type Subscription struct {
Snapshots <-chan registry.StateSnapshot
Errors <-chan error
// contains filtered or unexported fields
}
Subscription streams immutable effective-state snapshots until its context is canceled.
func (*Subscription) Close ¶
func (s *Subscription) Close()
Close cancels the subscription. It is safe to call more than once.