transport

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

capabilities.go

control.go

http.go

stream.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCSRFTokenHandler

func NewCSRFTokenHandler(mgr *security.CSRFManager, ttl time.Duration) http.Handler

NewCSRFTokenHandler returns the GET /csrf handler. ttl is the token validity window the response surfaces to the client; the underlying manager is the authority on validation.

func NewCapabilitiesHandler

func NewCapabilitiesHandler(reg contract.Registry, shellEnvelopes []string) http.Handler

NewCapabilitiesHandler returns the GET /capabilities handler.

func NewHandler

NewHandler returns the POST /api/dashboard/{envelope} handler.

func NewHandlerWithCSRF

func NewHandlerWithCSRF(reg contract.Registry, wreg contract.WardenRegistry, disp Dispatcher, audit contract.AuditEmitter, mgr *security.CSRFManager) http.Handler

NewHandlerWithCSRF is NewHandler plus a CSRFManager for command validation. When mgr is non-nil, command envelopes whose CSRF token does not validate return CodeUnauthenticated. Pass nil to skip CSRF (preserves the slice-(a) behaviour for tests and rollout opt-out).

Types

type CSRFTokenResponse

type CSRFTokenResponse struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expiresAt"`
}

CSRFTokenResponse is the wire shape for GET /api/dashboard/v1/csrf.

type CapabilitiesResponse

type CapabilitiesResponse struct {
	ShellEnvelopes []string                `json:"shellEnvelopes"`
	Contributors   []ContributorCapability `json:"contributors"`
}

CapabilitiesResponse is the wire shape for GET /capabilities.

type ContributorCapability

type ContributorCapability struct {
	Name      string             `json:"name"`
	Envelopes []string           `json:"envelopes"`
	Intents   []IntentCapability `json:"intents"`
}

ContributorCapability is one contributor's negotiable surface.

type ControlMessage

type ControlMessage struct {
	StreamID       string                          `json:"streamID"`
	Op             string                          `json:"op"` // "subscribe" | "unsubscribe"
	SubscriptionID string                          `json:"subscriptionID"`
	Contributor    string                          `json:"contributor,omitempty"`
	Intent         string                          `json:"intent,omitempty"`
	Params         map[string]contract.ParamSource `json:"params,omitempty"`
}

ControlMessage is one client request on POST /stream/control.

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, in contract.Request, p contract.Principal) (json.RawMessage, contract.ResponseMeta, error)
}

Dispatcher routes a fully-validated request to an intent implementation. Slice (c) provides the binding from intent name to actual handlers.

type IntentCapability

type IntentCapability struct {
	Name     string                `json:"name"`
	Versions []IntentVersionStatus `json:"versions"`
}

IntentCapability summarises one intent's available versions.

type IntentVersionStatus

type IntentVersionStatus struct {
	N           int    `json:"n"`
	Status      string `json:"status"` // active | deprecated
	RemoveAfter string `json:"removeAfter,omitempty"`
}

IntentVersionStatus reports a single version + lifecycle status.

type NilDispatcher

type NilDispatcher struct{}

NilDispatcher is the safe default when no real Dispatcher has been wired. Every dispatch returns a CodeUnavailable contract error so that callers see a clear, kind-agnostic failure instead of a nil panic.

func (NilDispatcher) Dispatch

Dispatch implements Dispatcher.

type StreamBroker

type StreamBroker struct {
	// contains filtered or unexported fields
}

StreamBroker manages active SSE connections + their subscriptions.

func NewStreamBroker

func NewStreamBroker(reg contract.Registry, wreg contract.WardenRegistry, source SubscriptionSource) *StreamBroker

NewStreamBroker returns a broker bound to a registry, warden registry, and source.

func (*StreamBroker) ServeControl

func (b *StreamBroker) ServeControl(w http.ResponseWriter, r *http.Request)

ServeControl handles POST /api/dashboard/v1/stream/control.

func (*StreamBroker) ServeStream

func (b *StreamBroker) ServeStream(w http.ResponseWriter, r *http.Request)

ServeStream implements GET /api/dashboard/v1/stream.

func (*StreamBroker) SnapshotIDs

func (b *StreamBroker) SnapshotIDs() []string

SnapshotIDs returns currently-active stream IDs (test helper / introspection).

type SubscriptionSource

type SubscriptionSource interface {
	Subscribe(ctx context.Context, p contract.Principal, contributor string, intent contract.Intent, params map[string]contract.ParamSource) (<-chan contract.StreamEvent, func(), error)
}

SubscriptionSource is the upstream events feeder. Slice (c) implements one for each contributor's subscription intents.

Jump to

Keyboard shortcuts

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