runtime

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidExecuteRequest = errors.New("invalid engine execute request")
	ErrExecutionNotFound     = errors.New("engine execution not found")
	// ErrIdentityConflict is the canonical identity-conflict sentinel. Durable
	// stores use the same sentinel so transports classify direct and raced
	// persistence conflicts consistently.
	ErrIdentityConflict   = schema.ErrIdentityConflict
	ErrGenerationMismatch = errors.New("engine generation mismatch")
	ErrBlockedDependency  = errors.New("execution blocked by missing dependency")
	ErrDurableDisposition = errors.New("durable execution disposition failed")
)
View Source
var (
	ErrGRPCInvalidInput      = errors.New("invalid gRPC execution input")
	ErrGRPCUnauthorized      = errors.New("gRPC authentication failed")
	ErrGRPCUnavailable       = errors.New("gRPC execution unavailable")
	ErrGRPCResourceExhausted = errors.New("gRPC execution resource exhausted")
)

Functions

func RegisterEngineExecutionServiceWithOptions

func RegisterEngineExecutionServiceWithOptions(registrar grpc.ServiceRegistrar, engine *Engine, options EngineExecutionServiceOptions) error

Types

type Admission

type Admission struct {
	ExecutionID              string         `json:"execution_id"`
	AdmissionID              string         `json:"admission_id,omitempty"`
	TenantNamespace          string         `json:"tenant_namespace"`
	Ruleset                  string         `json:"ruleset"`
	Version                  string         `json:"version"`
	Facts                    map[string]any `json:"facts"`
	MergePolicy              string         `json:"merge_policy,omitempty"`
	ExpectedGenerationDigest string         `json:"expected_generation_digest,omitempty"`
}

type ArtifactResolver

type ArtifactResolver interface {
	ResolveGeneration(context.Context, ledger.ExecutionArtifact) (*Generation, error)
}

ArtifactResolver reconstructs a callback-free Generation from one immutable durable artifact. It intentionally has no compiler or loader surface.

type ArtifactResolverFunc

type ArtifactResolverFunc func(context.Context, ledger.ExecutionArtifact) (*Generation, error)

func (ArtifactResolverFunc) ResolveGeneration added in v0.4.0

func (f ArtifactResolverFunc) ResolveGeneration(ctx context.Context, artifact ledger.ExecutionArtifact) (*Generation, error)

type BearerTokenAuthenticator

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

func NewBearerTokenAuthenticator

func NewBearerTokenAuthenticator(token string) (*BearerTokenAuthenticator, error)

func NewBearerTokenAuthenticatorSet

func NewBearerTokenAuthenticatorSet(tokens []string) (*BearerTokenAuthenticator, error)

func (*BearerTokenAuthenticator) Authenticate

func (authenticator *BearerTokenAuthenticator) Authenticate(ctx context.Context, _ string) (context.Context, error)

type Engine

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

Engine owns exactly one immutable Generation. A process must be replaced to execute a changed bundle; durable recovery resolves the generation pinned in the execution artifact rather than consulting mutable process state.

func NewEngine

func NewEngine(generation *Generation) (*Engine, error)

func (*Engine) ActiveGenerationDigest

func (engine *Engine) ActiveGenerationDigest() string

func (*Engine) Close added in v0.4.0

func (engine *Engine) Close() error

func (*Engine) ConfigureLedger

func (engine *Engine) ConfigureLedger(durable ledger.ExecutionLedger, resolver ArtifactResolver) error

func (*Engine) ConfigureWorkflow added in v0.4.0

func (engine *Engine) ConfigureWorkflow(store workflow.OutboxStore, provider fencing.Provider, options schema.DispatcherOptions) error

func (*Engine) DryRun added in v0.4.0

func (engine *Engine) DryRun(ctx context.Context, facts map[string]any) ([]PlanEvaluation, error)

func (*Engine) Execute

func (engine *Engine) Execute(ctx context.Context, request ExecuteRequest) (result ExecuteResult, resultErr error)

func (*Engine) Generation added in v0.4.0

func (engine *Engine) Generation() *Generation

func (*Engine) GenerationView added in v0.4.0

func (engine *Engine) GenerationView() *GenerationView

func (*Engine) SetObserver

func (engine *Engine) SetObserver(observer Observer)

type EngineExecutionService

type EngineExecutionService struct {
	effectusv1.UnimplementedRulesetExecutionServiceServer
	Engine *Engine
	// contains filtered or unexported fields
}

EngineExecutionService is the sole generated inbound gRPC facade. It has no mutable method registry and admits work only through Engine.Execute.

func (*EngineExecutionService) ExecuteRuleset

type EngineExecutionServiceOptions

type EngineExecutionServiceOptions struct {
	RulesetName string
	Version     string
}

type ExecuteRequest

type ExecuteRequest struct {
	Admission         *Admission
	ResumeExecutionID string
	WaitMode          WaitMode
	RecoveryLease     *schema.ExecutionLease
}

type ExecuteResult

type ExecuteResult struct {
	ExecutionID      string `json:"execution_id"`
	GenerationDigest string `json:"generation_digest"`
	State            string `json:"state"`
	DurablyAccepted  bool   `json:"durably_accepted"`
	Completed        bool   `json:"completed"`
}

type GRPCAuthenticator

type GRPCAuthenticator interface {
	Authenticate(context.Context, string) (context.Context, error)
}

type GRPCAuthenticatorFunc

type GRPCAuthenticatorFunc func(context.Context, string) (context.Context, error)

func (GRPCAuthenticatorFunc) Authenticate

func (function GRPCAuthenticatorFunc) Authenticate(ctx context.Context, method string) (context.Context, error)

type Generation

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

Generation is immutable after construction. Manager ownership and acquired handles are the only references counted for retirement.

func CompileGeneration added in v0.4.0

func CompileGeneration(ctx context.Context, config GenerationBuildConfig) (*Generation, error)

CompileGeneration compiles one source bundle exactly once, resolves every declared invocation descriptor, and freezes the resulting Generation.

func NewGeneration

func NewGeneration(config GenerationConfig) (*Generation, error)

func (*Generation) Checked

func (generation *Generation) Checked() *ir.Checked

func (*Generation) Close added in v0.4.0

func (generation *Generation) Close() error

Close retires all generation-owned resources exactly once in reverse acquisition order. A changed generation requires replacing the process.

func (*Generation) Closed

func (generation *Generation) Closed() bool

Closed reports whether generation-owned executor resources are retired.

func (*Generation) Digest

func (generation *Generation) Digest() string

func (*Generation) Environment

func (generation *Generation) Environment() ir.Environment

func (*Generation) Executor

func (generation *Generation) Executor(verb string) (invocation.Executor, bool)

func (*Generation) ExecutorDescriptors added in v0.4.0

func (generation *Generation) ExecutorDescriptors() map[string]invocation.Descriptor

ExecutorDescriptors returns the immutable resolver manifest.

func (*Generation) FunctionIDs added in v0.4.0

func (generation *Generation) FunctionIDs() map[string]string

FunctionIDs returns the immutable function resolver identities.

func (*Generation) Ruleset

func (generation *Generation) Ruleset() string

func (*Generation) SourceDigest

func (generation *Generation) SourceDigest() string

func (*Generation) Version

func (generation *Generation) Version() string

type GenerationBuildConfig added in v0.4.0

type GenerationBuildConfig struct {
	Bundle         *bundle.SourceBundle
	CompileOptions compiler.CompileOptions
	Resolvers      *invocation.Registry
	FunctionIDs    map[string]string
	Production     bool
}

GenerationBuildConfig is the single source-bundle to generation startup input.

type GenerationConfig

type GenerationConfig struct {
	Checked             *ir.Checked
	Environment         ir.Environment
	Ruleset             string
	Version             string
	ExecutorDescriptors map[string]invocation.Descriptor
	FunctionIDs         map[string]string
	SourceDigest        string
	Executors           map[string]invocation.Executor
	Closers             []io.Closer
	Production          bool
}

GenerationConfig contains every value covered by a generation digest.

type GenerationView added in v0.4.0

type GenerationView struct {
	Ruleset          string
	Version          string
	GenerationDigest string
	IRDigest         string
	SourceDigest     string
	Environment      ir.Environment
	Plans            []PlanView
}

type ManifestArtifactResolver

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

ManifestArtifactResolver rebuilds a generation only from the descriptor manifest durably pinned with an execution. No extension loader or callback implementation participates in recovery.

func NewManifestArtifactResolver

func NewManifestArtifactResolver(registries ...*invocation.Registry) *ManifestArtifactResolver

func (*ManifestArtifactResolver) ResolveGeneration added in v0.4.0

func (resolver *ManifestArtifactResolver) ResolveGeneration(ctx context.Context, artifact ledger.ExecutionArtifact) (*Generation, error)

type Observer

type Observer interface {
	ObserveExecution(ExecuteResult, error)
	ObserveRecovery(RecoveryObservation)
}

type PlanEvaluation added in v0.4.0

type PlanEvaluation struct {
	Plan    PlanView
	Matched bool
}

type PlanView added in v0.4.0

type PlanView struct {
	ID        string
	Dialect   effectusv1.SourceDialect
	Priority  int32
	Predicate string
	Verbs     []string
}

type RecoveryObservation

type RecoveryObservation struct {
	BacklogMeasured                     bool
	Backlog, Blocked                    int64
	OldestExecutionAge, OldestOutboxAge time.Duration
	ExecutionID, State                  string
	Err                                 error
}

type RecoveryWorker

type RecoveryWorker struct {
	Engine        *Engine
	Store         ledger.ExecutionLedger
	Owner         string
	BatchSize     int
	LeaseDuration time.Duration
	PollInterval  time.Duration
	Observer      Observer
}

func (*RecoveryWorker) Run

func (worker *RecoveryWorker) Run(ctx context.Context) error

Run polls until cancellation. Each poll is bounded by BatchSize.

func (*RecoveryWorker) RunOnce

func (worker *RecoveryWorker) RunOnce(ctx context.Context) (int, error)

RunOnce leases a bounded set of nonterminal executions and resumes each only through Engine.Execute. Lease completion is a CAS performed by the engine.

type RulesetExecutionServer

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

func NewRulesetExecutionServer

func NewRulesetExecutionServer(engine *Engine, addr string) (*RulesetExecutionServer, error)

func NewRulesetExecutionServerOnListener

func NewRulesetExecutionServerOnListener(engine *Engine, listener net.Listener, options RulesetExecutionServerOptions) (*RulesetExecutionServer, error)

func NewRulesetExecutionServerWithOptions

func NewRulesetExecutionServerWithOptions(engine *Engine, addr string, options RulesetExecutionServerOptions) (*RulesetExecutionServer, error)

func (*RulesetExecutionServer) Address

func (server *RulesetExecutionServer) Address() net.Addr

func (*RulesetExecutionServer) Ready

func (server *RulesetExecutionServer) Ready() error

func (*RulesetExecutionServer) Start

func (server *RulesetExecutionServer) Start() error

func (*RulesetExecutionServer) Stop

func (server *RulesetExecutionServer) Stop()

type RulesetExecutionServerOptions

type RulesetExecutionServerOptions struct {
	MaxReceiveBytes        int
	MaxSendBytes           int
	MaxExecutionDuration   time.Duration
	MaxConcurrentRPCs      int
	Authenticator          GRPCAuthenticator
	AllowUnauthenticated   bool
	TLSConfig              *tls.Config
	AllowInsecureTransport bool
	RulesetName            string
	Version                string
}

RulesetExecutionServerOptions defines the immutable service registration and transport policy. The generated service is registered in the constructor, before Serve can be called.

type WaitMode

type WaitMode string
const (
	WaitAccepted WaitMode = "accepted"
	WaitTerminal WaitMode = "terminal"
)

Directories

Path Synopsis
internal
db

Jump to

Keyboard shortcuts

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