operations

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: GPL-3.0 Imports: 21 Imported by: ? 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 (
	MaxInputBytes  = 64 << 10
	MaxOutputBytes = 64 << 10
	MaxJSONDepth   = 16
	DefaultTimeout = 30 * time.Second
	MaxTimeout     = 15 * time.Minute
)

Variables

View Source
var (
	ErrAuthorizationLost  = errors.New("admin session authorization lost")
	ErrOperationForbidden = errors.New("operation forbidden")
)
View Source
var ErrBusy = &SafeError{Code: "unavailable", Message: "operation capacity exhausted", Retryable: true}
View Source
var ErrConflict = &SafeError{Code: "idempotency_conflict", Message: "idempotency key was used with different input"}
View Source
var ErrInvalidSourceInvalidation = errors.New("invalid admin UI source invalidation")
View Source
var ErrInvalidationUnsupported = errors.New("operation source invalidation is not supported")
View Source
var ErrProgressUnsupported = errors.New("operation progress is not supported")

Functions

func RegisterTyped

func RegisterTyped[I any, O any](r *Registry, provider string, d Definition, handler func(context.Context, I) (O, error)) error

func ValidateSourceInvalidation

func ValidateSourceInvalidation(sourceID, key string) error

ValidateSourceInvalidation performs the deterministic validation handlers must run before committing a mutation that will emit an invalidation.

Types

type AuditFunc

type AuditFunc func(actor, action, target string, metadata map[string]any)

type Authorizer

type Authorizer struct {
	Sessions interface {
		RevalidateSession(context.Context, string) (*auth.IdentityAuthentication, error)
	}
	Registry *auth.Registry
}

func (Authorizer) AuthorizeOperation

func (a Authorizer) AuthorizeOperation(ctx context.Context, session, permission string) (*auth.IdentityAuthentication, error)

type Config

type Config struct {
	MaxRunning, MaxRunningPerPrincipal int
	MaxConcurrent                      int
	Lifecycle                          context.Context
	ProviderEnabled                    ProviderEnabled
	Audit                              AuditFunc
	InvalidateSource                   func(provider, sourceID, key string) error
}

type Definition

type Definition struct {
	ID                             string
	Version                        uint
	Permission, Title, Description string
	Timeout                        time.Duration
	OutputLimit                    int
	Progress                       bool
}

type Executor

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

func (*Executor) DroppedAudits

func (e *Executor) DroppedAudits() uint64

DroppedAudits reports overload in the bounded non-authoritative audit queue.

func (*Executor) Prepare

func (e *Executor) Prepare(q Request) (*Prepared, error)

func (*Executor) Shutdown

func (e *Executor) Shutdown()

func (*Executor) Status

type Handler

type Handler func(context.Context, Invocation) (json.RawMessage, error)

type Invocation

type Invocation struct {
	ExecutionID, PrincipalID, SessionID, OperationID string
	MutationID                                       string
	Version                                          uint
	Input                                            json.RawMessage
	// contains filtered or unexported fields
}

func (Invocation) InvalidateSource

func (i Invocation) InvalidateSource(sourceID, key string) error

InvalidateSource publishes a trusted-provider source invalidation. The provider is fixed by the operation registration and cannot be supplied by a handler.

func (Invocation) ReportProgress

func (i Invocation) ReportProgress(ctx context.Context, progress Progress) error

type Prepared

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

func (*Prepared) Submit

func (p *Prepared) Submit(ctx context.Context) (*Submission, error)

type Progress

type Progress struct {
	Current, Total uint64
	Message        string
}

type ProviderBatch

type ProviderBatch struct {
	Provider      string
	Registrations []Registration
}

type ProviderEnabled

type ProviderEnabled func(string) bool

type Registration

type Registration struct {
	Definition Definition
	Handler    Handler
}

type Registry

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

func NewRegistry

func NewRegistry(permissions ...*auth.Registry) *Registry

func (*Registry) Freeze

func (r *Registry) Freeze()

func (*Registry) Owns

func (r *Registry) Owns(provider, id string, version uint) bool

Owns reports whether the exact operation ID and version belong to provider. Provider identity is trusted registry metadata and is never inferred from ID.

func (*Registry) RegisterBatch

func (r *Registry) RegisterBatch(provider string, batch []Registration) error

func (*Registry) RegisterBatches

func (r *Registry) RegisterBatches(batches []ProviderBatch) error

func (*Registry) Snapshot

func (r *Registry) Snapshot(enabled ...ProviderEnabled) []Definition

type Request

type Request struct {
	SessionID, OperationID, IdempotencyKey string
	Version                                uint
	Input                                  []byte
}

type Result

type Result struct {
	Record            *storage.OperationRecord
	Replayed          bool
	AuthorizationLost bool
	Err               error
}

type SafeError

type SafeError struct {
	Code, Message string
	Retryable     bool
}

func (*SafeError) Error

func (e *SafeError) Error() string

type SessionAuthorizer

type SessionAuthorizer interface {
	AuthorizeOperation(context.Context, string, string) (*auth.IdentityAuthentication, error)
}

type StatusRequest

type StatusRequest struct {
	SessionID, OperationID, IdempotencyKey string
	Version                                uint
}

type Submission

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

func (*Submission) Done

func (s *Submission) Done() <-chan Result

func (*Submission) Progress

func (s *Submission) Progress() <-chan storage.OperationProgress

func (*Submission) Record

func (s *Submission) Record() *storage.OperationRecord

func (*Submission) Replayed

func (s *Submission) Replayed() bool

func (*Submission) Start

func (s *Submission) Start()

Jump to

Keyboard shortcuts

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