protocol

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 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 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

View Source
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.

View Source
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.

View Source
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.

View Source
const (
	HealthReady    = "READY"
	HealthNotReady = "NOT_READY"
)

Health statuses.

View Source
const MaxFeedEvents = 100

MaxFeedEvents is the most events one feed.observe call carries.

View Source
const Version1 = "basalt-plugin/1"

Version1 is the only protocol version there is.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

Marshal encodes v as compact JSON, as json.Marshal does but without escaping <, > and &. Transports encode messages with it, so the bytes of a notifier event reach a plugin as the engine built them, on every transport.

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 HealthRequest

type HealthRequest struct{}

HealthRequest is empty.

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 Model

type Model struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Model names the model behind a plugin, when it has one.

type RawObject

type RawObject []byte

RawObject is a JSON object kept as bytes. A nil value encodes as {}.

func (RawObject) MarshalJSON

func (r RawObject) MarshalJSON() ([]byte, error)

MarshalJSON returns the object, or {} when there is none.

func (*RawObject) UnmarshalJSON

func (r *RawObject) UnmarshalJSON(b []byte) error

UnmarshalJSON keeps a copy of the object's bytes.

type ShutdownRequest

type ShutdownRequest struct{}

ShutdownRequest is empty.

type ShutdownResponse

type ShutdownResponse struct{}

ShutdownResponse is empty.

Jump to

Keyboard shortcuts

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