Versions in this module Expand all Collapse all v1 v1.0.0 Nov 2, 2026 Changes in this version + const BatchPath + const BatchTarget + const CloseGoingAway + const CloseIdentityGone + const CloseNormal + const CloseTooSlow + const DefaultDistinctMaximum + const DefaultMaximumLimit + const ExportCSV + const FiltersPath + const FiltersTarget + const ParameterAfter + const ParameterField + const ParameterFilter + const ParameterFilterID + const ParameterFormat + const ParameterLimit + const ParameterOffset + const ParameterPresenceKey + const ParameterSort + const PresenceTable + func HistoryFields() query.Fields + func IdempotencyKeyFrom(ctx context.Context) string + func OwnerKey(identity *auth.Identity) string + func RedactItem(ctx context.Context, fields query.Fields, raw json.RawMessage) (json.RawMessage, error) + func RedactItems(ctx context.Context, fields query.Fields, raw json.RawMessage) (json.RawMessage, error) + func TenantFrom(ctx context.Context) string + func TransactionFrom(ctx context.Context) any + func WithIdempotencyKey(ctx context.Context, key string) context.Context + func WithTenant(ctx context.Context, tenant string) context.Context + func WithTransaction(ctx context.Context, handle any) context.Context + type AuditEntry struct + Duration time.Duration + IdempotencyKey string + Identity *auth.Identity + Mutation string + Parameters any + RequestID string + Status int + Tenant string + type AuditStore interface + Write func(ctx context.Context, entry *AuditEntry) error + type BatchCall struct + Body json.RawMessage + Parameters map[string]string + Target string + type BatchRequest struct + Body json.RawMessage + IdempotencyKey string + RequestID string + type BatchResult struct + Payload json.RawMessage + Status int + type CallDescriber interface + DescribeCall func(ctx context.Context, transactionDetails TransactionDetails) error + type CallRequest struct + Body []byte + IdempotencyKey string + RequestID string + Source ParameterSource + Target string + type Change struct + ID string + Operation ChangeOperation + Partition string + Table string + type ChangeFeed interface + Run func(ctx context.Context, onChange func(Change), onResync func()) error + type ChangeOperation string + const ChangeDelete + const ChangeInsert + const ChangeUpdate + type ClientIDVersion int + const ClientIDNone + const UUIDv4 + const UUIDv7 + type Code string + const CodeConflict + const CodeForbidden + const CodeForbiddenField + const CodeInProgress + const CodeInternal + const CodeInvalidCursor + const CodeInvalidFilter + const CodeInvalidPage + const CodeInvalidRequest + const CodeInvalidSort + const CodeNotFound + const CodeUnauthenticated + type Declaration interface + Check func() authorization.Check + DecodeParameters func(source ParameterSource) (any, error) + Kind func() Kind + Method func() string + Name func() string + Parameters func() []Parameter + Path func() string + Tables func() []string + type DistinctValue struct + Count int + Value any + type Effect struct + Kind EffectKind + Target string + func Removes(target string) Effect + func Upserts(target string) Effect + type EffectKind string + const EffectRemoves + const EffectUpserts + type Engine struct + func NewEngine(options *EngineOptions) (*Engine, error) + func (e *Engine) Batch(ctx context.Context, request BatchRequest) (json.RawMessage, error) + func (e *Engine) Call(ctx context.Context, request CallRequest) (status int, payload json.RawMessage, err error) + func (e *Engine) Close(ctx context.Context) error + func (e *Engine) DeleteFilter(ctx context.Context, id string) error + func (e *Engine) Export(ctx context.Context, request ExportRequest) (rows int, err error) + func (e *Engine) Handler() http.Handler + func (e *Engine) ListFilters(ctx context.Context, resource string) (json.RawMessage, error) + func (e *Engine) Read(ctx context.Context, request ReadRequest) (json.RawMessage, error) + func (e *Engine) Registry() *Registry + func (e *Engine) RevalidateAll() + func (e *Engine) RevalidateOwner(key string) + func (e *Engine) Run(ctx context.Context) error + func (e *Engine) SaveFilter(ctx context.Context, body []byte) (json.RawMessage, error) + func (e *Engine) ServesPresence() bool + func (e *Engine) Upload(ctx context.Context, request UploadRequest) (status int, payload json.RawMessage, err error) + type EngineOptions struct + AllowedOrigins []string + AuditStore AuditStore + ChangeFeed ChangeFeed + DeliveryBatchWait time.Duration + FilterStore FilterStore + FiltersPerSocket int + FrameBytes int64 + IdempotencyStore IdempotencyStore + IdentitySource IdentitySource + InFlightPerSocket int + PresenceExpiry time.Duration + PresenceHeartbeat time.Duration + PresenceStore PresenceStore + PresencesPerSocket int + QueryConcurrency int + QueuedBytesPerSocket int + Registry *Registry + RetryInterval time.Duration + RevalidateInterval time.Duration + SafetyTickInterval time.Duration + SameHostOnly bool + SocketsPerOwner int + SubscriptionsPerSocket int + Transactor Transactor + WriteTimeout time.Duration + type Error struct + func Conflict() *Error + func ForbiddenField(name string) *Error + func InProgress() *Error + func Invalid(fields map[string]string) *Error + func NotFound() *Error + func (e *Error) Body() ErrorBody + func (e *Error) Error() string + func (e *Error) Status() int + type ErrorBody struct + Code Code + Fields map[string]string + Message string + func ResponseFor(err error) (int, ErrorBody) + type ExportRequest struct + Source ParameterSource + Target string + Writer io.Writer + type File struct + Body io.Reader + ContentType string + Filename string + Size int64 + type FilterItem struct + Context string + CreatedAt time.Time + Filter json.RawMessage + ID string + LastUsedAt time.Time + Name string + Resource string + type FilterRequest struct + Context string + Filter json.RawMessage + Name string + Resource string + type FilterStore interface + Delete func(ctx context.Context, owner Owner, id string) error + Get func(ctx context.Context, owner Owner, id string) (*StoredFilter, error) + List func(ctx context.Context, owner Owner, resource string) ([]StoredFilter, error) + Save func(ctx context.Context, filter *StoredFilter) (*StoredFilter, error) + type GuardedField struct + Name string + Read authorization.Check + type IdempotencyRecord struct + Key string + Mutation string + Owner Owner + Response json.RawMessage + Status int + type IdempotencyStore interface + Record func(ctx context.Context, record *IdempotencyRecord) error + Reserve func(ctx context.Context, owner Owner, key, mutation string) (record *IdempotencyRecord, replay bool, err error) + type IdentitySource interface + Identify func(ctx context.Context, request *http.Request) (*auth.Identity, error) + type ItemKey struct + Field string + Parameter string + type Kind string + const KindList + const KindMutation + const KindObject + const KindResource + const KindUpload + type List struct + func NewList[Item, Parameters any](name, path string, options *ListOptions[Item, Parameters]) *List + func (l *List) Fields() query.Fields + func (l *List) ItemType() reflect.Type + func (l *List) Kind() Kind + func (l *List) Load(ctx context.Context, parameters any) (any, error) + func (l *List) Partition() PartitionResolver + func (s *List) Check() authorization.Check + func (s *List) DecodeParameters(source ParameterSource) (any, error) + func (s *List) Method() string + func (s *List) Name() string + func (s *List) Parameters() []Parameter + func (s *List) Path() string + func (s *List) Tables() []string + type ListChange struct + Order []string + Removes []string + Total *int + Upserts []json.RawMessage + type ListOptions struct + Guarded []GuardedField + Load func(ctx context.Context, parameters *Parameters) ([]Item, error) + Partition PartitionResolver + Read authorization.Check + Tables []string + type ListResponse struct + Items []Item + Limit int + Next *string + Offset int + Total int + type ListState struct + func NewListState(rawItems json.RawMessage, total int) (*ListState, error) + func (s *ListState) ChangesSince(previous *ListState) *ListChange + func (s *ListState) Snapshot() json.RawMessage + type MapSource map[string]string + func (s MapSource) Path(name string) (string, bool) + func (s MapSource) Query(name string) ([]string, bool) + type Mutation struct + func NewMutation[Parameters, Request, Response any](name, method, path string, ...) *Mutation + func (m *Mutation) ClientID() ClientIDVersion + func (m *Mutation) DecodeBody(ctx context.Context, raw []byte) (any, error) + func (m *Mutation) Effect() Effect + func (m *Mutation) Handle(ctx context.Context, parameters, body any) (any, error) + func (m *Mutation) HasBody() bool + func (m *Mutation) HasContent() bool + func (m *Mutation) Kind() Kind + func (m *Mutation) ParametersType() reflect.Type + func (m *Mutation) RequestType() reflect.Type + func (m *Mutation) Resource() string + func (m *Mutation) ResponseType() reflect.Type + func (m *Mutation) Status() int + func (s *Mutation) Check() authorization.Check + func (s *Mutation) DecodeParameters(source ParameterSource) (any, error) + func (s *Mutation) Method() string + func (s *Mutation) Name() string + func (s *Mutation) Parameters() []Parameter + func (s *Mutation) Path() string + func (s *Mutation) Tables() []string + type MutationOptions struct + Check authorization.Check + ClientID ClientIDVersion + Effect Effect + FieldChecks map[string]authorization.Check + Handle func(ctx context.Context, parameters *Parameters, body *Request) (*Response, error) + Resource string + Status int + type NoBody struct + type NoContent struct + type NoParameters struct + type Object struct + func NewObject[Item, Parameters any](name, path string, options *ObjectOptions[Item, Parameters]) *Object + func (l *Object) Partition() PartitionResolver + func (o *Object) Fields() query.Fields + func (o *Object) ItemType() reflect.Type + func (o *Object) Kind() Kind + func (o *Object) Load(ctx context.Context, parameters any) (any, error) + func (o *Object) PresencePath() string + func (s *Object) Check() authorization.Check + func (s *Object) DecodeParameters(source ParameterSource) (any, error) + func (s *Object) Method() string + func (s *Object) Name() string + func (s *Object) Parameters() []Parameter + func (s *Object) Path() string + func (s *Object) Tables() []string + type ObjectOptions struct + Guarded []GuardedField + Load func(ctx context.Context, parameters *Parameters) (*Item, error) + Partition PartitionResolver + Read authorization.Check + Tables []string + type Observer func(ctx context.Context, outcome Outcome) + type Operation string + const OperationBatch + const OperationCall + const OperationJoin + const OperationLeave + const OperationPing + const OperationQuery + const OperationSubscribe + const OperationUnsubscribe + type Outcome struct + Duration time.Duration + Err error + Identity *auth.Identity + Kind OutcomeKind + Operation Operation + Parameters any + QueryWait time.Duration + Rows int + Status int + Subscription string + Target string + Tenant string + type OutcomeKind string + const OutcomeAfterCommit + const OutcomeBatch + const OutcomeCall + const OutcomeClose + const OutcomeEnd + const OutcomeExport + const OutcomeFeed + const OutcomeHeartbeat + const OutcomeOpen + const OutcomeRequest + const OutcomeRerun + const OutcomeRevalidate + const OutcomeSubscribe + type Owner struct + Key string + Tenant string + func OwnerOf(ctx context.Context) (Owner, bool) + type Page struct + Items []Item + Next *query.Cursor + Total int + type Parameter struct + Enum []string + In ParameterIn + List bool + Name string + Type reflect.Type + func (p Parameter) Required() bool + type ParameterIn string + const InPath + const InQuery + type ParameterSource interface + Path func(name string) (string, bool) + Query func(name string) ([]string, bool) + type PartitionResolver func(ctx context.Context, parameters any) string + type Presence struct + Display string + Key string + Owner Owner + Socket string + State json.RawMessage + Target string + UpdatedAt time.Time + type PresenceItem struct + Display string + ID string + State json.RawMessage + type PresenceStore interface + Heartbeat func(ctx context.Context, socket string) error + Join func(ctx context.Context, presence *Presence) error + Leave func(ctx context.Context, tenant, socket, target, key string) error + List func(ctx context.Context, tenant, target, key string) ([]Presence, error) + Sweep func(ctx context.Context, maximumAge time.Duration) (int, error) + type PushFrame struct + Kind PushKind + Payload json.RawMessage + Sequence int64 + Subscription string + type PushKind string + const PushError + const PushListChange + const PushReplace + const PushSnapshot + type ReadKind string + const ReadDistinct + const ReadHistory + const ReadItem + const ReadMain + const ReadPresence + type ReadParameters struct + After string + Field string + Filter json.RawMessage + FilterID string + Limit string + Offset string + Sort string + func ReadParametersFrom(source ParameterSource) (*ReadParameters, error) + type ReadRequest struct + Kind ReadKind + Source ParameterSource + Target string + type Registry struct + func NewRegistry(options *RegistryOptions) (*Registry, error) + func (r *Registry) Add(declarations ...Declaration) error + func (r *Registry) BasePath() string + func (r *Registry) Declarations() []Declaration + func (r *Registry) Lookup(name string) (Declaration, bool) + func (r *Registry) Observe(ctx context.Context, outcome Outcome) + func (r *Registry) Tenant(ctx context.Context, parameters any) (string, error) + type RegistryOptions struct + BasePath string + Observer Observer + Tenant func(ctx context.Context, parameters any) (string, error) + type RequestFrame struct + Body json.RawMessage + ID string + IdempotencyKey string + Operation Operation + Parameters map[string]string + Target string + type Resource struct + func NewResource[Item any](name, path string, options *ResourceOptions[Item]) *Resource + func (l *Resource) Partition() PartitionResolver + func (r *Resource) Cursor() bool + func (r *Resource) DefaultSort() []query.SortTerm + func (r *Resource) DistinctPath() string + func (r *Resource) DistinctQuery(ctx context.Context, parameters *ReadParameters) (*query.ListQuery, query.Field, error) + func (r *Resource) ExportColumns() []string + func (r *Resource) ExportPath() string + func (r *Resource) Fields() query.Fields + func (r *Resource) HistoryPath() string + func (r *Resource) Item() *ItemKey + func (r *Resource) ItemPath() string + func (r *Resource) ItemQuery(ctx context.Context, source ParameterSource) (*query.ListQuery, error) + func (r *Resource) ItemType() reflect.Type + func (r *Resource) Kind() Kind + func (r *Resource) ListQuery(ctx context.Context, parameters *ReadParameters) (*query.ListQuery, error) + func (r *Resource) LoadDistinct(ctx context.Context, field string, listQuery *query.ListQuery) ([]DistinctValue, error) + func (r *Resource) LoadItem(ctx context.Context, listQuery *query.ListQuery) (any, error) + func (r *Resource) LoadList(ctx context.Context, listQuery *query.ListQuery) (any, error) + func (r *Resource) PresencePath() string + func (r *Resource) Versioned() bool + func (s *Resource) Check() authorization.Check + func (s *Resource) DecodeParameters(source ParameterSource) (any, error) + func (s *Resource) Method() string + func (s *Resource) Name() string + func (s *Resource) Parameters() []Parameter + func (s *Resource) Path() string + func (s *Resource) Tables() []string + type ResourceOptions struct + CountCap int + Cursor bool + DefaultSort []query.SortTerm + Distinct func(ctx context.Context, field string, listQuery *query.ListQuery) ([]DistinctValue, error) + DistinctMaximum int + Export func(ctx context.Context, listQuery *query.ListQuery, columns query.Fields, ...) (int, error) + ExportColumns []string + Fields query.Fields + Get func(ctx context.Context, listQuery *query.ListQuery) (*Item, error) + History func(ctx context.Context, listQuery *query.ListQuery) (*Page[Version[Item]], error) + Item *ItemKey + List func(ctx context.Context, listQuery *query.ListQuery) (*Page[Item], error) + MaximumLimit int + Partition PartitionResolver + Read authorization.Check + Scope func(ctx context.Context) (query.Predicate, error) + Tables []string + Versioned bool + type ResponseFrame struct + Error *ErrorBody + FilterID string + ID string + OK bool + Payload json.RawMessage + Status int + Subscription string + type StoredFilter struct + Context string + CreatedAt time.Time + Document json.RawMessage + Hash string + ID string + LastUsedAt time.Time + Name string + Owner Owner + Resource string + type Transaction interface + Commit func(ctx context.Context) error + Handle func() any + Rollback func(ctx context.Context) error + type TransactionDetails struct + Identity *auth.Identity + Mutation string + Parameters any + ReadOnly bool + RequestID string + Tenant string + type Transactor interface + Begin func(ctx context.Context, transactionDetails TransactionDetails) (Transaction, error) + type Upload struct + func NewUpload[Parameters, Response any](name, path string, options *UploadOptions[Parameters, Response]) *Upload + func (s *Upload) Check() authorization.Check + func (s *Upload) DecodeParameters(source ParameterSource) (any, error) + func (s *Upload) Method() string + func (s *Upload) Name() string + func (s *Upload) Parameters() []Parameter + func (s *Upload) Path() string + func (s *Upload) Tables() []string + func (u *Upload) Accepts(contentType string) string + func (u *Upload) ContentTypes() []string + func (u *Upload) Handle(ctx context.Context, parameters any, file *File) (any, error) + func (u *Upload) Kind() Kind + func (u *Upload) MaximumBytes() int64 + func (u *Upload) ParametersType() reflect.Type + func (u *Upload) ResponseType() reflect.Type + func (u *Upload) Status() int + type UploadOptions struct + Check authorization.Check + ContentTypes []string + Handle func(ctx context.Context, parameters *Parameters, file *File) (*Response, error) + MaximumBytes int64 + Status int + type UploadRequest struct + File *File + IdempotencyKey string + RequestID string + Source ParameterSource + Target string + type Version struct + Actor string + Data *Item + ID int + Mutation string + Operation ChangeOperation + RealActor string + RequestID string + ValidFrom time.Time + ValidTo *time.Time