server

package
v0.1.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 33 Imported by: 0 modules, 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

Index

Constants

View Source
const CollectionAccessManifestSchemaURL = "https://crapthings.github.io/meldbase/schemas/collection-access-manifest-v1.schema.json"

CollectionAccessManifestSchemaURL identifies the schema used to validate collection access manifests.

It is optional metadata, but when present the strict parser accepts only this exact versioned URL.

View Source
const CollectionAccessManifestVersion = 1

CollectionAccessManifestVersion identifies the supported collection access manifest format.

Manifests contain only data so tools and agents can generate and validate the same server configuration.

View Source
const (
	// ProtocolVersion is the current realtime/RPC envelope version.
	//
	// Existing
	// versions are immutable; incompatible grammar requires a new version.
	ProtocolVersion = 1
)

Variables

View Source
var (
	// ErrUnauthenticated reports that a request has no accepted application identity.
	ErrUnauthenticated = errors.New("meldbase server: unauthenticated")
	// ErrForbidden reports that the requested operation is not authorized.
	ErrForbidden = errors.New("meldbase server: forbidden")
)
View Source
var ErrInvalidPolicyLease = errors.New("meldbase server: invalid query policy lease")

ErrInvalidPolicyLease reports an invalid policy version or missing lease where a lease is required.

Functions

This section is empty.

Types

type Actor

type Actor struct {
	ID          string
	WorkspaceID string
}

Actor identifies the authenticated user or service and active workspace for a request.

ID is the stable user or service identifier; WorkspaceID comes from the verified credential.

type Authenticator

type Authenticator interface {
	AuthenticateHTTP(*http.Request) (Actor, error)
}

Authenticator verifies an HTTP request's credentials and returns its application identity.

type Authorizer

Authorizer supplies server-enforced policies for document reads, inserts, updates, and deletions.

type CollectionAccess

type CollectionAccess struct {
	Collection string                  `json:"collection"`
	Mode       CollectionAccessMode    `json:"mode"`
	OwnerField string                  `json:"ownerField,omitempty"`
	Fields     *CollectionAccessFields `json:"fields,omitempty"`
}

CollectionAccess declares the read and write rules for one collection.

OwnerField is required only for CollectionAccessOwner.

type CollectionAccessFields

type CollectionAccessFields struct {
	QueryPaths      []string `json:"queryPaths,omitempty"`
	AggregateFields []string `json:"aggregateFields,omitempty"`
	ResultFields    []string `json:"resultFields,omitempty"`
	InputFields     []string `json:"inputFields,omitempty"`
	UpdatePaths     []string `json:"updatePaths,omitempty"`
}

CollectionAccessFields lists the fields clients may use for each operation.

A nil list allows every field for that operation; an explicit empty list allows none. Server-owned workspace and owner fields remain immutable regardless of these declarations.

type CollectionAccessManifest

type CollectionAccessManifest struct {
	SchemaURL      string             `json:"$schema,omitempty"`
	Version        int                `json:"version"`
	WorkspaceField string             `json:"workspaceField"`
	Collections    []CollectionAccess `json:"collections"`
	RPCMethods     []string           `json:"rpcMethods,omitempty"`
}

CollectionAccessManifest declares collection access rules without executable authorization callbacks.

Complex membership or role rules still use an application Authorizer or Worker policy resolver, both of which return the same server-enforced policy types.

func ParseCollectionAccessManifestJSON

func ParseCollectionAccessManifestJSON(data []byte) (CollectionAccessManifest, error)

ParseCollectionAccessManifestJSON decodes and validates a collection access manifest.

It rejects unknown fields, trailing values, unsupported versions, and invalid collection declarations.

func (CollectionAccessManifest) WorkspaceAuthorizerConfig

func (manifest CollectionAccessManifest) WorkspaceAuthorizerConfig() (WorkspaceAuthorizerConfig, error)

WorkspaceAuthorizerConfig validates the manifest and converts it into built-in access settings.

type CollectionAccessMode

type CollectionAccessMode string

CollectionAccessMode selects the read and write permissions for a collection.

Modes only produce the existing policy types; they do not introduce a second authorization engine or client-side checks.

const (
	// CollectionAccessCollaborative allows verified workspace members to read and change collection documents.
	//
	// The server owns the workspace field; use this mode for shared workspace data.
	CollectionAccessCollaborative CollectionAccessMode = "collaborative"
	// CollectionAccessOwner limits access to documents the actor owns within its verified workspace.
	//
	// The server owns both the workspace and owner
	// fields for inserts and makes them immutable afterwards.
	CollectionAccessOwner CollectionAccessMode = "owner"
	// CollectionAccessRPCOnly rejects generic queries and mutations while allowing separately authorized RPC methods.
	CollectionAccessRPCOnly CollectionAccessMode = "rpc_only"
	// CollectionAccessReadOnly allows workspace reads and subscriptions while rejecting generic mutations.
	//
	// It is intended for
	// business records whose writes are named server RPC operations.
	CollectionAccessReadOnly CollectionAccessMode = "read_only"
)

type Config

type Config struct {
	DB                             *meldbase.DB
	Authenticator                  Authenticator
	Authorizer                     Authorizer
	QueryPolicyResolver            QueryPolicyResolver
	PublicRealtimeURL              string
	OriginPatterns                 []string
	AllowedHTTPOrigins             []string
	TicketTTL                      time.Duration
	ResumeTokenKey                 []byte
	ResumeTokenTTL                 time.Duration
	MaxBodyBytes                   int
	MaxQueryResultBytes            int
	MaxRealtimeFrameBytes          int
	MaxRealtimeOutboundBytes       int
	MaxSubscriptionsPerConnection  int
	QueryLimits                    meldbase.QueryLimits
	ReplaySource                   meldbase.QueryReplaySource
	RPCMethods                     map[string]RPCMethod
	RPCTransactionalMethods        map[string]RPCTransactionalMethod
	RPCMethodResolver              RPCMethodResolver
	RPCTransactionalMethodResolver RPCTransactionalMethodResolver
	RPCAuthorizer                  RPCAuthorizer
	MaxConcurrentRPC               int
	MaxRPCPerConnection            int
	MaxRPCResultBytes              int
	RPCIdempotencyStore            RPCIdempotencyStore
	RPCIdempotencyRetention        time.Duration
	RPCIdempotencyCommitTimeout    time.Duration
	AuditWriter                    io.Writer
	RequestRateLimitPerMinute      int
	RequestRateLimitBurst          int
	RequestRateLimitMaxSubjects    int
	TrustedProxyCIDRs              []string
}

Config sets the database, security policies, transport limits, and optional RPC services for a handler.

type DeletePolicy

type DeletePolicy struct {
	QueryPolicy
	MaxAffected int
}

DeletePolicy combines row-selection permissions with an affected-document limit.

type DurablePolicyGenerationStore

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

DurablePolicyGenerationStore reads policy generations from database system records.

func NewDurablePolicyGenerationStore

func NewDurablePolicyGenerationStore(db *meldbase.DB) (*DurablePolicyGenerationStore, error)

NewDurablePolicyGenerationStore creates a policy generation reader backed by an open database.

func (*DurablePolicyGenerationStore) LoadPolicyGeneration

func (store *DurablePolicyGenerationStore) LoadPolicyGeneration(ctx context.Context, collection string) ([16]byte, bool, error)

LoadPolicyGeneration reads and validates the system record for a collection's policy generation.

type DurableRPCIdempotencyStore

type DurableRPCIdempotencyStore interface {
	RPCIdempotencyStore
	RPCIdempotencyMaintenance
}

DurableRPCIdempotencyStore combines durable request ownership with expired-record maintenance.

func NewDurableRPCIdempotencyStore

func NewDurableRPCIdempotencyStore(db *meldbase.DB) (DurableRPCIdempotencyStore, error)

NewDurableRPCIdempotencyStore creates an idempotency store backed by database system records.

type HS256JWTAuthenticator

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

HS256JWTAuthenticator verifies signed tokens and identifies their user or service and active workspace.

Tokens must use HS256 and fit within the accepted size limits.

func NewHS256JWTAuthenticator

func NewHS256JWTAuthenticator(config HS256JWTAuthenticatorConfig) (*HS256JWTAuthenticator, error)

NewHS256JWTAuthenticator validates settings and copies the active signing secrets into a new authenticator.

func (*HS256JWTAuthenticator) AuthenticateHTTP

func (a *HS256JWTAuthenticator) AuthenticateHTTP(request *http.Request) (Actor, error)

AuthenticateHTTP verifies an HS256 bearer token and returns its subject and workspace as an actor.

type HS256JWTAuthenticatorConfig

type HS256JWTAuthenticatorConfig struct {
	// Secret is retained for single-key deployments. Secrets permits a bounded
	// overlap window while a signing key is rotated; it must not be set together
	// with Secret.
	Secret         []byte
	Secrets        [][]byte
	Issuer         string
	Audience       string
	WorkspaceClaim string
	Clock          func() time.Time
}

HS256JWTAuthenticatorConfig sets the signing secrets and claim rules for HS256 bearer-token verification.

type Handler

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

Handler serves authorized database operations and manages realtime connection services.

func New

func New(config Config) (*Handler, error)

New validates and normalizes server settings and registers the HTTP routes.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP enforces request limits and HTTP origin rules before routing and recording the response.

func (*Handler) Stats

func (h *Handler) Stats() ServerStats

Stats captures server activity counters and statistics from a configured worker hub.

type InsertPolicy

type InsertPolicy struct {
	AllowAllInputFields  bool
	AllowedInputFields   map[string]struct{}
	SetFields            meldbase.Document
	AllowAllResultFields bool
	AllowedResultFields  map[string]struct{}
}

InsertPolicy defines accepted input fields, server-owned field values, and permitted result fields.

type MeldbaseError

type MeldbaseError struct {
	Code string
	Data meldbase.Document
}

MeldbaseError carries an expected business error code and optional safe data for the caller.

Code is a namespaced stable identifier (for example "orders.already_paid"); Data is an optional safe document sent to the caller. Arbitrary handler errors are always classified as MeldbaseInternalError instead.

func (*MeldbaseError) Error

func (err *MeldbaseError) Error() string

Error returns the application error code as diagnostic text.

type MeldbaseInternalError

type MeldbaseInternalError struct {
	Code   string
	Status int
}

MeldbaseInternalError carries a server-owned RPC error code and HTTP status.

Applications should return MeldbaseError for deliberate business outcomes and let all other failures be safely normalized by the server.

func (*MeldbaseInternalError) Error

func (err *MeldbaseInternalError) Error() string

Error returns the server-owned error code as diagnostic text.

type PolicyGenerationStore

type PolicyGenerationStore interface {
	LoadPolicyGeneration(context.Context, string) ([16]byte, bool, error)
}

PolicyGenerationStore reads a collection's persisted policy generation.

type QueryPolicy

type QueryPolicy struct {
	PolicyVersion string
	Lease         *QueryPolicyLease
	Constraint    *meldbase.QuerySpec
	MaxResults    int
	// Deprecated compatibility grant. New policies should use the separate
	// filter and sort capability fields below.
	AllowAllQueryPaths      bool
	AllowedQueryPaths       map[string]struct{}
	AllowAllFilterPaths     bool
	AllowedFilterPaths      map[string]struct{}
	AllowAllFilterOperators bool
	AllowedFilterOperators  map[string]map[string]struct{}
	AllowAllSortPaths       bool
	AllowedSortPaths        map[string]struct{}
	AllowAllAggregateFields bool
	AllowedAggregateFields  map[string]struct{}
	AllowAllResultFields    bool
	AllowedResultFields     map[string]struct{}
	// contains filtered or unexported fields
}

QueryPolicy defines row constraints, field permissions, result limits, and revocation leases for a query.

type QueryPolicyLease

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

QueryPolicyLease coordinates policy revocation with authorized response delivery.

Revoke first prevents new acquisitions and closes Done, then waits for every acquisition already encoding or enqueueing a response to finish. Frames already placed in the transport queue are considered authorized in flight. One lease may be shared by many subscriptions governed by the same version.

func NewQueryPolicyLease

func NewQueryPolicyLease(version string) (*QueryPolicyLease, error)

NewQueryPolicyLease creates an active lease for a nonempty policy version.

func (*QueryPolicyLease) Done

func (lease *QueryPolicyLease) Done() <-chan struct{}

Done returns the channel closed on revocation or nil for a nil lease.

func (*QueryPolicyLease) Revoke

func (lease *QueryPolicyLease) Revoke(ctx context.Context) error

Revoke blocks new authorized actions and waits for existing actions to finish.

Repeated calls are safe. A canceled context stops waiting but does not undo revocation; a later call may wait for the same lease to drain.

func (*QueryPolicyLease) Valid

func (lease *QueryPolicyLease) Valid() bool

Valid reports whether a non-nil lease has not been revoked.

func (*QueryPolicyLease) Version

func (lease *QueryPolicyLease) Version() string

Version returns the policy version or an empty string for a nil lease.

type QueryPolicyResolver

type QueryPolicyResolver interface {
	ResolveQueryPolicy(context.Context, Actor, string, meldbase.QuerySpec) (QueryPolicy, bool, error)
}

QueryPolicyResolver optionally supplies an additional policy that narrows an already-authorized query.

A missing resolution preserves the base policy, while a resolver error rejects the query.

type RPCAuthorizer

type RPCAuthorizer interface {
	AuthorizeRPC(context.Context, Actor, string) error
}

RPCAuthorizer checks call permission before input decoding or application execution.

Registration alone never grants call permission.

type RPCIdempotencyClaim

type RPCIdempotencyClaim struct {
	ScopeHash   [32]byte
	KeyHash     [32]byte
	Fingerprint [32]byte
	SessionID   [16]byte
	ClaimID     [16]byte
	ExpiresAt   time.Time
}

RPCIdempotencyClaim identifies a pending request and the session that owns it.

The claim is persisted before application code starts. ScopeHash and KeyHash keep raw identities and caller keys out of stored record keys. SessionID and ClaimID are compare-and-set ownership tokens.

type RPCIdempotencyCompletion

type RPCIdempotencyCompletion struct {
	Claim       RPCIdempotencyClaim
	Result      []byte
	ErrorKind   string
	ErrorCode   string
	ErrorData   []byte
	ErrorStatus int
}

RPCIdempotencyCompletion pairs a claim with the result or error to persist.

type RPCIdempotencyDecision

type RPCIdempotencyDecision struct {
	Kind        RPCIdempotencyDecisionKind
	Result      []byte
	ErrorKind   string
	ErrorCode   string
	ErrorData   []byte
	ErrorStatus int
}

RPCIdempotencyDecision carries the store's execution decision or recorded result or error.

type RPCIdempotencyDecisionKind

type RPCIdempotencyDecisionKind uint8

RPCIdempotencyDecisionKind identifies whether an RPC may execute or must use a previously recorded outcome.

const (
	// RPCIdempotencyExecute grants ownership of a new pending request.
	RPCIdempotencyExecute RPCIdempotencyDecisionKind = iota + 1
	// RPCIdempotencyReplayResult returns a previously recorded successful result.
	RPCIdempotencyReplayResult
	// RPCIdempotencyReplayError returns a previously recorded error.
	RPCIdempotencyReplayError
	// RPCIdempotencyInProgress reports that the same request is still pending in the current session.
	RPCIdempotencyInProgress
	// RPCIdempotencyOutcomeUnknown reports that the request cannot safely be executed again because its outcome is uncertain.
	RPCIdempotencyOutcomeUnknown
	// RPCIdempotencyConflict reports that the key was used for a different request.
	RPCIdempotencyConflict
)

type RPCIdempotencyMaintenance

type RPCIdempotencyMaintenance interface {
	// PruneExpired removes up to the requested number of expired records with known or unknown outcomes.
	//
	// Pending records are never removed by time alone.
	PruneExpired(context.Context, int) (int, error)
}

RPCIdempotencyMaintenance removes expired terminal records without discarding pending requests.

type RPCIdempotencyStore

RPCIdempotencyStore records request ownership and outcomes so repeated calls cannot execute unsafely.

Operations must be linearizable and durable. Claim must publish a new pending record before returning Execute. Complete and MarkUnknown are CAS transitions matching SessionID and ClaimID. Implementations must never turn a pending record owned by another session back into Execute.

type RPCMethod

type RPCMethod func(context.Context, Actor, meldbase.Value) (meldbase.Value, error)

RPCMethod handles an authenticated application call whose effects are not atomic with its result.

Input and results use Meldbase's closed Value model, preserving Int64, Date, Binary and object semantics across Go and JavaScript. Any database write or external effect a handler reaches outside a WriteTransaction is not atomic with its RPC terminal result.

type RPCMethodResolver

type RPCMethodResolver interface {
	ResolveRPCMethod(string) (RPCMethod, bool)
}

RPCMethodResolver looks up trusted-worker methods when the local method registry has no match.

type RPCTransactionalMethod

type RPCTransactionalMethod func(context.Context, Actor, meldbase.Value, *meldbase.WriteTransaction) (meldbase.Value, error)

RPCTransactionalMethod stages database writes that commit together with a successful RPC result.

Writes use a short immutable snapshot. A successful result and all staged writes share one durable publication with the RPC idempotency terminal record after optimistic commit validation.

type RPCTransactionalMethodResolver

type RPCTransactionalMethodResolver interface {
	ResolveRPCTransactionalMethod(string) (RPCTransactionalMethod, bool)
}

RPCTransactionalMethodResolver looks up dynamically registered methods that stage database writes.

type RS256JWKSAuthenticator

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

RS256JWKSAuthenticator verifies bearer tokens using cached RSA signing keys from a JWKS endpoint.

func NewRS256JWKSAuthenticator

func NewRS256JWKSAuthenticator(config RS256JWKSAuthenticatorConfig) (*RS256JWKSAuthenticator, error)

NewRS256JWKSAuthenticator validates settings and creates an authenticator with an initially empty key cache.

func (*RS256JWKSAuthenticator) AuthenticateHTTP

func (a *RS256JWKSAuthenticator) AuthenticateHTTP(request *http.Request) (Actor, error)

AuthenticateHTTP verifies an RS256 bearer token and returns its subject and workspace as an actor.

type RS256JWKSAuthenticatorConfig

type RS256JWKSAuthenticatorConfig struct {
	JWKSURL        string
	Issuer         string
	Audience       string
	WorkspaceClaim string
	HTTPClient     *http.Client
	Clock          func() time.Time
	CacheTTL       time.Duration
}

RS256JWKSAuthenticatorConfig sets the public key source and rules for verifying signed tokens.

Issuer and audience are required so a token minted for a different API cannot become a Meldbase credential.

type ServerStats

type ServerStats struct {
	CapturedAt                time.Time      `json:"capturedAt"`
	StartedAt                 time.Time      `json:"startedAt"`
	ActiveConnections         uint64         `json:"activeConnections"`
	ConnectionsAccepted       uint64         `json:"connectionsAccepted"`
	RealtimeOutboundOverflows uint64         `json:"realtimeOutboundOverflows"`
	RPCRequests               uint64         `json:"rpcRequests"`
	RPCActive                 uint64         `json:"rpcActive"`
	RPCSucceeded              uint64         `json:"rpcSucceeded"`
	RPCFailed                 uint64         `json:"rpcFailed"`
	RPCCanceled               uint64         `json:"rpcCanceled"`
	RPCRejected               uint64         `json:"rpcRejected"`
	RPCBusy                   uint64         `json:"rpcBusy"`
	RPCRequestBytes           uint64         `json:"rpcRequestBytes"`
	RPCResultBytes            uint64         `json:"rpcResultBytes"`
	RPCTotalNanos             uint64         `json:"rpcTotalNanos"`
	RPCMaxLatency             time.Duration  `json:"rpcMaxLatencyNanos"`
	RPCIdempotencyClaims      uint64         `json:"rpcIdempotencyClaims"`
	RPCIdempotencyReplays     uint64         `json:"rpcIdempotencyReplays"`
	RPCIdempotencyConflicts   uint64         `json:"rpcIdempotencyConflicts"`
	RPCIdempotencyInProgress  uint64         `json:"rpcIdempotencyInProgress"`
	RPCIdempotencyUnknown     uint64         `json:"rpcIdempotencyUnknown"`
	RPCIdempotencyFailures    uint64         `json:"rpcIdempotencyFailures"`
	RPCAtomicCommits          uint64         `json:"rpcAtomicCommits"`
	RPCAtomicRollbacks        uint64         `json:"rpcAtomicRollbacks"`
	RPCAtomicNoopCompletions  uint64         `json:"rpcAtomicNoopCompletions"`
	HTTPUnauthenticated       uint64         `json:"httpUnauthenticated"`
	HTTPForbidden             uint64         `json:"httpForbidden"`
	HTTPRateLimited           uint64         `json:"httpRateLimited"`
	Worker                    WorkerHubStats `json:"worker"`
}

ServerStats reports aggregate server activity during the current process session.

It contains no method, actor, workspace, argument, result, or error text.

type UpdatePolicy

type UpdatePolicy struct {
	QueryPolicy
	AllowAllUpdatePaths bool
	AllowedUpdatePaths  map[string]struct{}
	DeniedUpdatePaths   map[string]struct{}
	MaxAffected         int
}

UpdatePolicy combines row-selection permissions with writable paths and an affected-document limit.

type WorkerAuthenticator

type WorkerAuthenticator interface {
	AuthenticateWorker(*http.Request) (WorkerIdentity, error)
}

WorkerAuthenticator verifies worker credentials separately from application credentials.

Client authenticators must never be reused implicitly for worker connections.

func NewWorkerTokenAuthenticator

func NewWorkerTokenAuthenticator(token string) (WorkerAuthenticator, error)

NewWorkerTokenAuthenticator creates a bearer token authenticator for workers using constant-time comparisons.

The raw token is not retained after construction.

type WorkerHub

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

WorkerHub routes calls to methods registered by separately authenticated workers.

Mount it on a private control listener and pass it as both resolver fields when transactional worker methods are desired.

func NewWorkerHub

func NewWorkerHub(config WorkerHubConfig) (*WorkerHub, error)

NewWorkerHub validates and normalizes worker settings and creates an empty registration hub.

func (*WorkerHub) ResolveQueryPolicy

func (hub *WorkerHub) ResolveQueryPolicy(ctx context.Context, actor Actor, collection string, query meldbase.QuerySpec) (QueryPolicy, bool, error)

ResolveQueryPolicy evaluates a managed collection's worker policy and rejects access when its worker is unavailable.

func (*WorkerHub) ResolveRPCMethod

func (hub *WorkerHub) ResolveRPCMethod(name string) (RPCMethod, bool)

ResolveRPCMethod returns a callable adapter for a registered non-transactional worker method.

func (*WorkerHub) ResolveRPCTransactionalMethod

func (hub *WorkerHub) ResolveRPCTransactionalMethod(name string) (RPCTransactionalMethod, bool)

ResolveRPCTransactionalMethod returns a callable adapter for a registered transaction-aware worker method.

func (*WorkerHub) ServeHTTP

func (hub *WorkerHub) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP authenticates and registers a worker WebSocket before processing its protocol messages.

func (*WorkerHub) Stats

func (hub *WorkerHub) Stats() WorkerHubStats

Stats captures the hub's connection, call, protocol, and policy counters.

type WorkerHubConfig

type WorkerHubConfig struct {
	Authenticator            WorkerAuthenticator
	ReadPolicyCollections    []string
	RegistrationTimeout      time.Duration
	MaxFrameBytes            int
	MaxMethodsPerWorker      int
	MaxReadPoliciesPerWorker int
	MaxPendingCalls          int
	MaxOperationsPerCall     int
	PolicyQueryLimits        meldbase.QueryLimits
	PolicyEvaluationTimeout  time.Duration
	PolicyGenerationStore    PolicyGenerationStore
}

WorkerHubConfig sets worker authentication, registration limits, and dynamic read-policy controls.

type WorkerHubStats

type WorkerHubStats struct {
	ConnectedWorkers       uint64 `json:"connectedWorkers"`
	RegisteredMethods      uint64 `json:"registeredMethods"`
	RegisteredReadPolicies uint64 `json:"registeredReadPolicies"`
	CallsStarted           uint64 `json:"callsStarted"`
	CallsActive            uint64 `json:"callsActive"`
	CallsSucceeded         uint64 `json:"callsSucceeded"`
	CallsFailed            uint64 `json:"callsFailed"`
	CallsCanceled          uint64 `json:"callsCanceled"`
	CallsBusy              uint64 `json:"callsBusy"`
	ProtocolFailures       uint64 `json:"protocolFailures"`
	BytesReceived          uint64 `json:"bytesReceived"`
	BytesSent              uint64 `json:"bytesSent"`
	TransactionOps         uint64 `json:"transactionOps"`
	PolicyEvaluations      uint64 `json:"policyEvaluations"`
	PolicyActive           uint64 `json:"policyActive"`
	PolicySucceeded        uint64 `json:"policySucceeded"`
	PolicyDenied           uint64 `json:"policyDenied"`
	PolicyFailed           uint64 `json:"policyFailed"`
	PolicyCanceled         uint64 `json:"policyCanceled"`
	PolicyBusy             uint64 `json:"policyBusy"`
	PolicyInvalidations    uint64 `json:"policyInvalidations"`
}

WorkerHubStats captures worker connection, execution, protocol, and policy activity counters.

type WorkerIdentity

type WorkerIdentity struct{ ID string }

WorkerIdentity identifies an authenticated worker that registers methods and read policies.

It is separate from the application Actor passed to RPC and read-policy handlers.

type WorkspaceAuthorizer

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

WorkspaceAuthorizer enforces declared collection and RPC permissions within the actor's active workspace.

An external identity provider supplies Actor.WorkspaceID from the active workspace claim; this authorizer does not store users or memberships.

func NewWorkspaceAuthorizer

func NewWorkspaceAuthorizer(config WorkspaceAuthorizerConfig) (*WorkspaceAuthorizer, error)

NewWorkspaceAuthorizer validates collection rules and creates workspace-scoped access policies.

func (*WorkspaceAuthorizer) AuthorizeDelete

func (a *WorkspaceAuthorizer) AuthorizeDelete(ctx context.Context, actor Actor, collection string, query meldbase.QuerySpec) (DeletePolicy, error)

AuthorizeDelete returns scoped deletion permissions and the affected-document limit.

func (*WorkspaceAuthorizer) AuthorizeInsert

func (a *WorkspaceAuthorizer) AuthorizeInsert(_ context.Context, actor Actor, collection string, _ meldbase.Document) (InsertPolicy, error)

AuthorizeInsert returns insert permissions and server-owned workspace and owner fields.

func (*WorkspaceAuthorizer) AuthorizeQuery

func (a *WorkspaceAuthorizer) AuthorizeQuery(_ context.Context, actor Actor, collection string, _ meldbase.QuerySpec) (QueryPolicy, error)

AuthorizeQuery returns field permissions and workspace or owner constraints for a collection read.

func (*WorkspaceAuthorizer) AuthorizeRPC

func (a *WorkspaceAuthorizer) AuthorizeRPC(_ context.Context, actor Actor, method string) error

AuthorizeRPC accepts only exact method names declared by the manifest, for a verified workspace actor.

The allowlist deliberately grants no role or record-level authority; those decisions remain in the named RPC handler.

func (*WorkspaceAuthorizer) AuthorizeUpdate

func (a *WorkspaceAuthorizer) AuthorizeUpdate(ctx context.Context, actor Actor, collection string, query meldbase.QuerySpec, _ meldbase.MutationSpec) (UpdatePolicy, error)

AuthorizeUpdate returns scoped update permissions that keep workspace and owner fields immutable.

type WorkspaceAuthorizerConfig

type WorkspaceAuthorizerConfig struct {
	CollectionAccess []CollectionAccess
	WorkspaceField   string
	RPCMethods       []string
	MaxResults       int
	MaxAffected      int
}

WorkspaceAuthorizerConfig sets collection and RPC permissions within the authenticated workspace.

The server owns the workspace field: inserts set it and updates may never modify it.

Jump to

Keyboard shortcuts

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