Documentation
¶
Overview ¶
Package oob provides minimal, generic primitives to manage out-of-band (OOB) interactions using typed pending entries bound to a namespace.
The package centralizes only the lifecycle and remapping concerns: - Create a pending interaction tied to the caller's namespace - Look up by ID and map back to the correct namespace - Complete or cancel a pending interaction - Minimal HTTP helper to inject the correct namespace into context based on ID
UI and flow specifics (device code pages, forms, redirects) are left entirely to the service. This keeps services free to present OOB in any way while guaranteeing that callbacks are mapped to the right namespace.
Index ¶
- Variables
- func IntoContext[T any](ctx context.Context, p Pending[T]) context.Context
- func NamespaceFromPending[T any](store Store[T], extract idExtractor, ...) http.Handler
- type CallbackBuilder
- type Manager
- type MemoryStore
- func (s *MemoryStore[T]) Cancel(ctx context.Context, id string) (Pending[T], bool, error)
- func (s *MemoryStore[T]) ClearNamespace(_ context.Context, ns string) ([]string, error)
- func (s *MemoryStore[T]) Complete(_ context.Context, id string) (Pending[T], bool, error)
- func (s *MemoryStore[T]) Get(_ context.Context, id string) (Pending[T], bool, error)
- func (s *MemoryStore[T]) ListNamespace(_ context.Context, ns string) ([]Pending[T], error)
- func (s *MemoryStore[T]) Put(_ context.Context, p Pending[T]) error
- type Pending
- type Spec
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrMisconfigured = errors.New("oob: misconfigured manager (missing Provider, Store or CallbackBuilder)")
ErrMisconfigured indicates a missing Provider, Store, or CallbackBuilder.
Functions ¶
func IntoContext ¶
IntoContext stores a Pending[T] in context.
func NamespaceFromPending ¶
func NamespaceFromPending[T any](store Store[T], extract idExtractor, next func(context.Context, Pending[T], http.ResponseWriter, *http.Request) error) http.Handler
NamespaceFromPending wraps a handler to remap the request to the correct namespace based on the pending id stored in the provided Store. It loads the pending, injects a minimal namespace descriptor into context, then calls next.
Types ¶
type CallbackBuilder ¶
CallbackBuilder returns a callback URL for the given id. The service should register a route that extracts this id and uses NamespaceFromPending to remap to the correct namespace.
type Manager ¶
type Manager[T any] struct { Provider namespace.Provider Store Store[T] CallbackBuilder CallbackBuilder }
Manager coordinates creation and completion of typed pendings with namespace resolution and callback URL generation.
func (*Manager[T]) Cancel ¶
Cancel removes and returns the pending entry for the given id without signaling completion.
type MemoryStore ¶
type MemoryStore[T any] struct { // contains filtered or unexported fields }
MemoryStore is an in-memory implementation of Store[T]. It is concurrency-safe and intended for single-process deployments or testing.
func NewMemoryStore ¶
func NewMemoryStore[T any]() *MemoryStore[T]
func (*MemoryStore[T]) ClearNamespace ¶
func (*MemoryStore[T]) ListNamespace ¶
type Pending ¶
type Pending[T any] struct { ID string Namespace string Kind string // e.g., "device_code", "basic_credentials", "oauth_redirect", etc. Alias string // optional account/connector alias Resource string // provider domain/tenant/connector ElicitID string // optional: if MCP Elicit was used to notify client CreatedAt time.Time ExpiresAt time.Time Data T // service-specific payload }
Pending represents a typed pending interaction bound to a namespace. T holds service-specific payload (e.g., device-code message, form schema).
type Spec ¶
type Spec[T any] struct { Namespace string // ignored; filled from context at Create Kind string Alias string Resource string ElicitID string ExpiresAt time.Time // optional expiry time Data T }
Spec carries inputs to create a Pending; Namespace is ignored on input and assigned from the caller context when creating the pending.
type Store ¶
type Store[T any] interface { Put(ctx context.Context, p Pending[T]) error Get(ctx context.Context, id string) (Pending[T], bool, error) Complete(ctx context.Context, id string) (Pending[T], bool, error) Cancel(ctx context.Context, id string) (Pending[T], bool, error) // Optional helper endpoints ListNamespace(ctx context.Context, namespace string) ([]Pending[T], error) ClearNamespace(ctx context.Context, namespace string) ([]string, error) }
Store is a generic backing registry for typed pendings; it is the source of truth mapping id -> namespace (and payload). Implementations may be in-memory or persistent.