schema

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangePublisher

type ChangePublisher interface {
	Notify(ctx context.Context, actorID uuid.UUID, metadata map[string]any)
}

ChangePublisher adapts schema change notifications to external systems (e.g., websockets, message buses, webhook fan-out).

type Listener

type Listener func(context.Context, Snapshot)

Listener receives registry snapshots whenever schemas change.

type Notifier

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

Notifier provides a simple observer pattern so validation listeners can trigger schema refreshes in admin consumers.

func NewNotifier

func NewNotifier() *Notifier

NewNotifier constructs a schema notifier.

func (*Notifier) Notify

func (n *Notifier) Notify(ctx context.Context, actorID uuid.UUID, metadata map[string]any)

Notify emits a schema refresh event to all registered listeners.

func (*Notifier) Register

func (n *Notifier) Register(listener func(context.Context, uuid.UUID, map[string]any))

Register adds a listener that receives actor notifications. Nil listeners are ignored.

type Option

type Option func(*Registry)

Option customizes registry behaviour.

func WithInfo

func WithInfo(info router.OpenAPIInfo) Option

WithInfo overrides the default OpenAPI info metadata.

func WithPublisher

func WithPublisher(publisher ChangePublisher) Option

WithPublisher wires a publisher used to notify listeners outside the process (e.g., websocket hubs) whenever schemas change.

func WithRelationProvider

func WithRelationProvider(provider router.RelationMetadataProvider) Option

WithRelationProvider configures a custom relation metadata provider for the generated documents.

func WithTags

func WithTags(tags ...string) Option

WithTags sets global tags applied to every generated OpenAPI document.

func WithUISchemaOptions

func WithUISchemaOptions(opts router.UISchemaOptions) Option

WithUISchemaOptions applies UI-specific schema enrichment callbacks.

type Registry

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

Registry tracks controller metadata so go-users can expose an aggregated schema endpoint and publish change events to downstream consumers.

func NewRegistry

func NewRegistry(opts ...Option) *Registry

NewRegistry constructs a registry with optional configuration.

func (*Registry) Document

func (r *Registry) Document() map[string]any

Document compiles the currently registered providers into a single OpenAPI document. Nil is returned when no providers are registered yet.

func (*Registry) Handler

func (r *Registry) Handler() router.HandlerFunc

Handler returns a go-router handler that serves the aggregated schema document from the `/admin/schemas` endpoint (or any route the caller chooses).

func (*Registry) Register

func (r *Registry) Register(provider router.MetadataProvider)

Register adds a metadata provider to the registry. Subsequent registrations with the same resource name replace the previous snapshot.

func (*Registry) RegisterAll

func (r *Registry) RegisterAll(providers ...router.MetadataProvider)

RegisterAll is a convenience helper that registers multiple providers.

func (*Registry) Resources

func (r *Registry) Resources() []string

Resources returns the registered resource names sorted for determinism.

func (*Registry) Subscribe

func (r *Registry) Subscribe(listener Listener)

Subscribe attaches a listener invoked each time the registry snapshot is refreshed (typically whenever a new controller registers).

type Snapshot

type Snapshot struct {
	GeneratedAt   time.Time
	ResourceNames []string
	Document      map[string]any
}

Snapshot captures a moment-in-time export of the registered schemas.

Jump to

Keyboard shortcuts

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