Documentation
¶
Overview ¶
Package protocol holds the Go types for the Basalt plugin protocol messages that every transport carries: initialize, health and shutdown, the notifier hooks, and the hooks declaration shared with the manifest. The field names match the JSON schemas of the engine's contract; unknown JSON fields are ignored on decode.
Plugin authors use package basaltplugin, which speaks the protocol for them. This package is for code that speaks it directly, such as a client written to test a plugin.
Index ¶
- Constants
- func Marshal(v any) ([]byte, error)
- type ApprovalDeliverRequest
- type ApprovalDeliverResponse
- type FeedObserveRequest
- type FeedObserveResponse
- type HealthRequest
- type HealthResponse
- type HookDecl
- type InitializeRequest
- type InitializeResponse
- type Limits
- type Model
- type RawObject
- type ShutdownRequest
- type ShutdownResponse
Constants ¶
const ( MethodFeedObserve = "feed.observe" MethodApprovalDeliver = "approval.deliver" )
The notifier hooks' methods, as the JSON-RPC method names. ConnectRPC maps them to PluginService/FeedObserve and ApprovalDeliver.
const ( MethodInitialize = "initialize" MethodHealth = "health" MethodShutdown = "shutdown" )
The lifecycle methods, as the JSON-RPC method names. ConnectRPC maps them to PluginService/Initialize, Health and Shutdown.
const ( // MaxMessageBytes is the largest message either side may send. MaxMessageBytes = 4 << 20 // MaxInFlight is the number of hook calls the engine keeps open on one // entry. health and shutdown are not counted: each has a slot of its own. MaxInFlight = 4 )
Limits every connection runs under.
const ( HealthReady = "READY" HealthNotReady = "NOT_READY" )
Health statuses.
const MaxFeedEvents = 100
MaxFeedEvents is the most events one feed.observe call carries.
const Version1 = "basalt-plugin/1"
Version1 is the only protocol version there is.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApprovalDeliverRequest ¶
type ApprovalDeliverRequest struct {
Agent string `json:"agent"`
Event json.RawMessage `json:"event"`
}
ApprovalDeliverRequest is one approval.deliver call (deliver/1): one notice, a CloudEvent in its JSON form, kept as bytes like a feed batch.
type ApprovalDeliverResponse ¶
type ApprovalDeliverResponse struct{}
ApprovalDeliverResponse is empty.
type FeedObserveRequest ¶
type FeedObserveRequest struct {
Agent string `json:"agent"`
Events json.RawMessage `json:"events"`
}
FeedObserveRequest is one feed.observe call (feed/1): one agent's events, in ascending seq. Events is the CloudEvents JSON batch, kept as bytes so the events reach the plugin as the engine built them, on every transport.
type FeedObserveResponse ¶
type FeedObserveResponse struct {
LastSeq int64 `json:"lastSeq"`
}
FeedObserveResponse is the plugin's answer: the seq of the last event it handled, which must be the data.seq of one event of the batch.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
}
HealthResponse is the plugin's reply to health.
type HookDecl ¶
type HookDecl struct {
Contract string `json:"contract,omitempty"`
Roles []string `json:"roles,omitempty"`
EntityTypes []string `json:"entityTypes,omitempty"`
}
HookDecl is what a plugin declares for one hook, in the manifest and in the initialize reply.
type InitializeRequest ¶
type InitializeRequest struct {
Protocols []string `json:"protocols"`
Hooks []string `json:"hooks"`
// Config is the entry's config from engine.json, {} when it has none.
Config RawObject `json:"config"`
Limits Limits `json:"limits"`
}
InitializeRequest is the first call on every connection.
type InitializeResponse ¶
type InitializeResponse struct {
Protocol string `json:"protocol"`
Name string `json:"name"`
Version string `json:"version"`
Hooks map[string]HookDecl `json:"hooks"`
Model *Model `json:"model,omitempty"`
}
InitializeResponse is the plugin's reply.
type Limits ¶
type Limits struct {
MaxMessageBytes int `json:"maxMessageBytes"`
MaxInFlight int `json:"maxInFlight"`
TimeoutMs int `json:"timeoutMs"`
}
Limits is sent to the plugin in initialize.
type RawObject ¶
type RawObject []byte
RawObject is a JSON object kept as bytes. A nil value encodes as {}.
func (RawObject) MarshalJSON ¶
MarshalJSON returns the object, or {} when there is none.
func (*RawObject) UnmarshalJSON ¶
UnmarshalJSON keeps a copy of the object's bytes.