Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- func (c *Config) BuildUniqueID() string
- func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Config) CloneVT() *Config
- func (this *Config) EqualMessageVT(thatMsg any) bool
- func (this *Config) EqualVT(that *Config) bool
- func (c *Config) EqualsConfig(other config.Config) bool
- func (x *Config) GetAllowNonExecController() bool
- func (x *Config) GetClaimId() string
- func (x *Config) GetClaimLease() string
- func (c *Config) GetConfigID() string
- func (x *Config) GetEngineId() string
- func (x *Config) GetInputWorld() *target.InputWorld
- func (x *Config) GetObjectKey() string
- func (x *Config) GetPeerId() string
- func (x *Config) GetResolveControllerConfigTimeout() string
- func (x *Config) GetWorkerObjectKey() string
- func (x *Config) MarshalJSON() ([]byte, error)
- func (x *Config) MarshalProtoJSON(s *json.MarshalState)
- func (x *Config) MarshalProtoText() string
- func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Config) MarshalToVT(dAtA []byte) (int, error)
- func (m *Config) MarshalVT() (dAtA []byte, err error)
- func (c *Config) ParseClaimLease() (time.Duration, error)
- func (c *Config) ParsePeerID() (peer.ID, error)
- func (c *Config) ParseResolveControllerConfigTimeout() (time.Duration, error)
- func (*Config) ProtoMessage()
- func (x *Config) Reset()
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (x *Config) UnmarshalJSON(b []byte) error
- func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Config) UnmarshalVT(dAtA []byte) error
- func (c *Config) Validate() error
- type Controller
- func (c *Controller) CancelWaitCh() <-chan struct{}
- func (c *Controller) CheckExecControllerConfig(ctx context.Context, conf config.Config) error
- func (c *Controller) Close() error
- func (c *Controller) Execute(ctx context.Context) error
- func (c *Controller) GetControllerInfo() *controller.Info
- func (c *Controller) HandleDirective(ctx context.Context, inst directive.Instance) ([]directive.Resolver, error)
- func (c *Controller) ProcessState(ctx context.Context, le *logrus.Entry, ws world.WorldState, ...) (waitForChanges bool, err error)
- type ExecConfig
- func (m *ExecConfig) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *ExecConfig) CloneVT() *ExecConfig
- func (this *ExecConfig) EqualMessageVT(thatMsg any) bool
- func (this *ExecConfig) EqualVT(that *ExecConfig) bool
- func (x *ExecConfig) GetExecution() *execution.Execution
- func (x *ExecConfig) GetTarget() *target.Target
- func (x *ExecConfig) MarshalJSON() ([]byte, error)
- func (x *ExecConfig) MarshalProtoJSON(s *json.MarshalState)
- func (x *ExecConfig) MarshalProtoText() string
- func (m *ExecConfig) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *ExecConfig) MarshalToVT(dAtA []byte) (int, error)
- func (m *ExecConfig) MarshalVT() (dAtA []byte, err error)
- func (*ExecConfig) ProtoMessage()
- func (x *ExecConfig) Reset()
- func (m *ExecConfig) SizeVT() (n int)
- func (x *ExecConfig) String() string
- func (x *ExecConfig) UnmarshalJSON(b []byte) error
- func (x *ExecConfig) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *ExecConfig) UnmarshalVT(dAtA []byte) error
- type Factory
- func (t *Factory) Construct(ctx context.Context, conf config.Config, opts controller.ConstructOpts) (controller.Controller, error)
- func (t *Factory) ConstructConfig() config.Config
- func (t *Factory) GetConfigID() string
- func (t *Factory) GetControllerID() string
- func (t *Factory) GetVersion() controller.Version
- type Lease
Constants ¶
const ConfigID = ControllerID
ConfigID is the string used to identify this config object.
const ControllerID = "forge/execution"
ControllerID is the ID of the controller.
Variables ¶
var ErrNotExecController = errors.New("controller does not implement ExecController")
ErrNotExecController is returned if a exec.controller does not implement target.ExecController.
var Version = controller.MustParseVersion("0.0.1")
Version is the version of the controller implementation.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// EngineId is the world engine id for the forge state.
EngineId string `protobuf:"bytes,1,opt,name=engine_id,json=engineId,proto3" json:"engineId,omitempty"`
// ObjectKey is the Execution state object to attach to.
// If not exists, waits for it to exist.
ObjectKey string `protobuf:"bytes,2,opt,name=object_key,json=objectKey,proto3" json:"objectKey,omitempty"`
// PeerId is the peer ID to use for the execution controller.
// Must match the Execution peer except when reclaiming an expired claim.
// If not set, will look up the peer id from the state.
PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
// ResolveControllerConfigTimeout is a timeout for resolving the exec.controller config.
ResolveControllerConfigTimeout string `` /* 152-byte string literal not displayed */
// AllowNonExecController allows exec.controller to not implement ExecController.
AllowNonExecController bool `` /* 129-byte string literal not displayed */
// InputWorld is the default value for the "world" input.
InputWorld *target.InputWorld `protobuf:"bytes,6,opt,name=input_world,json=inputWorld,proto3" json:"inputWorld,omitempty"`
// ClaimId is the stable owner token used across controller retries.
ClaimId string `protobuf:"bytes,7,opt,name=claim_id,json=claimId,proto3" json:"claimId,omitempty"`
// ClaimLease is how long a claim stays live without renewal, as a duration
// string. The controller renews at a third of the lease. Peers may reclaim
// an Execution once its holder has missed the lease. Defaults to five minutes.
ClaimLease string `protobuf:"bytes,8,opt,name=claim_lease,json=claimLease,proto3" json:"claimLease,omitempty"`
// WorkerObjectKey selects the Worker's placement on reclaim. Required when
// reclaiming a placed Execution; the peer must be linked to this Worker.
WorkerObjectKey string `protobuf:"bytes,9,opt,name=worker_object_key,json=workerObjectKey,proto3" json:"workerObjectKey,omitempty"`
// contains filtered or unexported fields
}
Config is the execution controller configuration.
func NewConfig ¶
func NewConfig(engineID, objectKey string, peerID peer.ID, inpWorld *forge_target.InputWorld) *Config
NewConfig constructs a new execution controller config. Sets the most important fields only.
func (*Config) BuildUniqueID ¶
BuildUniqueID builds the durable execution controller ID.
func (*Config) CloneMessageVT ¶
func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Config) EqualMessageVT ¶
func (*Config) EqualsConfig ¶
EqualsConfig checks if the other config is equal.
func (*Config) GetAllowNonExecController ¶
func (*Config) GetClaimId ¶ added in v0.57.0
func (*Config) GetClaimLease ¶
func (*Config) GetConfigID ¶
GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.
func (*Config) GetEngineId ¶
func (*Config) GetInputWorld ¶
func (x *Config) GetInputWorld() *target.InputWorld
func (*Config) GetObjectKey ¶
func (*Config) GetResolveControllerConfigTimeout ¶
func (*Config) GetWorkerObjectKey ¶
func (*Config) MarshalJSON ¶
MarshalJSON marshals the Config to JSON.
func (*Config) MarshalProtoJSON ¶
func (x *Config) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Config message to JSON.
func (*Config) MarshalProtoText ¶
func (*Config) MarshalToSizedBufferVT ¶
func (*Config) ParseClaimLease ¶
ParseClaimLease parses a lease longer than the clock-skew allowance.
func (*Config) ParsePeerID ¶
ParsePeerID parses the peer ID field.
func (*Config) ParseResolveControllerConfigTimeout ¶
ParseResolveControllerConfigTimeout parses the timeout dur.
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Config from JSON.
func (*Config) UnmarshalProtoJSON ¶
func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Config message from JSON.
func (*Config) UnmarshalVT ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller implements the Execution controller. An Execution is an attempt to process a given Target. Usually constructed & managed by the Pass controller. Spawns "exec" controllers on the provided bus.
func NewController ¶
NewController constructs a new Execution controller. Note: exec.controller instances will be run on the given bus.
func StartControllerWithConfig ¶
func StartControllerWithConfig( ctx context.Context, b bus.Bus, conf *Config, ) (*Controller, directive.Reference, error)
StartControllerWithConfig starts a execution controller with a config. Waits for the controller to start. Returns a Release function to close the controller when done.
func (*Controller) CancelWaitCh ¶ added in v0.57.2
func (c *Controller) CancelWaitCh() <-chan struct{}
CancelWaitCh returns a channel that closes once durable cancellation of the execution has been observed.
func (*Controller) CheckExecControllerConfig ¶
CheckExecControllerConfig checks if the controller config is OK to execute.
func (*Controller) Close ¶
func (c *Controller) Close() error
Close releases any resources used by the controller. Error indicates any issue encountered releasing.
func (*Controller) Execute ¶
func (c *Controller) Execute(ctx context.Context) error
Execute executes the controller. Returning nil ends execution. Returning an error triggers a retry with backoff.
func (*Controller) GetControllerInfo ¶
func (c *Controller) GetControllerInfo() *controller.Info
GetControllerInfo returns information about the controller.
func (*Controller) HandleDirective ¶
func (c *Controller) HandleDirective(ctx context.Context, inst directive.Instance) ([]directive.Resolver, error)
HandleDirective asks if the handler can resolve the directive.
func (*Controller) ProcessState ¶
func (c *Controller) ProcessState( ctx context.Context, le *logrus.Entry, ws world.WorldState, obj world.ObjectState, rootRef *bucket.ObjectRef, rev uint64, ) (waitForChanges bool, err error)
ProcessState implements the state reconciliation loop.
NOTE: the Execution may be updated by the controller several times during execution.
type ExecConfig ¶
type ExecConfig struct {
// Execution is the current state of the execution.
// NOTE: value_set and result are set to nil.
Execution *execution.Execution `protobuf:"bytes,1,opt,name=execution,proto3" json:"execution,omitempty"`
// Target is the current target to execute.
// This is the value of the TargetRef in execution.
Target *target.Target `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"`
// contains filtered or unexported fields
}
ExecConfig is a configuration for the execution routine.
func (*ExecConfig) CloneMessageVT ¶
func (m *ExecConfig) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*ExecConfig) CloneVT ¶
func (m *ExecConfig) CloneVT() *ExecConfig
func (*ExecConfig) EqualMessageVT ¶
func (this *ExecConfig) EqualMessageVT(thatMsg any) bool
func (*ExecConfig) EqualVT ¶
func (this *ExecConfig) EqualVT(that *ExecConfig) bool
func (*ExecConfig) GetExecution ¶
func (x *ExecConfig) GetExecution() *execution.Execution
func (*ExecConfig) GetTarget ¶
func (x *ExecConfig) GetTarget() *target.Target
func (*ExecConfig) MarshalJSON ¶
func (x *ExecConfig) MarshalJSON() ([]byte, error)
MarshalJSON marshals the ExecConfig to JSON.
func (*ExecConfig) MarshalProtoJSON ¶
func (x *ExecConfig) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the ExecConfig message to JSON.
func (*ExecConfig) MarshalProtoText ¶
func (x *ExecConfig) MarshalProtoText() string
func (*ExecConfig) MarshalToSizedBufferVT ¶
func (m *ExecConfig) MarshalToSizedBufferVT(dAtA []byte) (int, error)
func (*ExecConfig) MarshalToVT ¶
func (m *ExecConfig) MarshalToVT(dAtA []byte) (int, error)
func (*ExecConfig) MarshalVT ¶
func (m *ExecConfig) MarshalVT() (dAtA []byte, err error)
func (*ExecConfig) ProtoMessage ¶
func (*ExecConfig) ProtoMessage()
func (*ExecConfig) Reset ¶
func (x *ExecConfig) Reset()
func (*ExecConfig) SizeVT ¶
func (m *ExecConfig) SizeVT() (n int)
func (*ExecConfig) String ¶
func (x *ExecConfig) String() string
func (*ExecConfig) UnmarshalJSON ¶
func (x *ExecConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the ExecConfig from JSON.
func (*ExecConfig) UnmarshalProtoJSON ¶
func (x *ExecConfig) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the ExecConfig message from JSON.
func (*ExecConfig) UnmarshalVT ¶
func (m *ExecConfig) UnmarshalVT(dAtA []byte) error
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory constructs a Execution controller.
func (*Factory) Construct ¶
func (t *Factory) Construct( ctx context.Context, conf config.Config, opts controller.ConstructOpts, ) (controller.Controller, error)
Construct constructs the associated controller given configuration.
func (*Factory) ConstructConfig ¶
ConstructConfig constructs an instance of the controller configuration.
func (*Factory) GetConfigID ¶
GetConfigID returns the unique ID for the config.
func (*Factory) GetControllerID ¶
GetControllerID returns the unique ID for the controller.
func (*Factory) GetVersion ¶
func (t *Factory) GetVersion() controller.Version
GetVersion returns the version of this controller.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease renews one granted claim and cancels its operation ClaimClockSkew before the last committed expiry. Renewal and settlement stop permanently on a stale epoch. Reclaim cannot overlap operation when the reclaimer's clock lead plus operation's cancellation drain time stays within ClaimClockSkew.
func NewLease ¶
func NewLease(le *logrus.Entry, expiry time.Time, duration time.Duration, renew func(context.Context, time.Time) error) *Lease
NewLease constructs a lease for one granted claim with duration greater than ClaimClockSkew. renew must honor cancellation and report success only after the new expiry commits. Construction and Execute require an already granted claim.
func (*Lease) Execute ¶
Execute runs and drains operation under the committed lease. A failed or blocked renewal cannot delay cancellation past expiry minus ClaimClockSkew. Losing the lease returns nil so a routine does not restart the same claim. Execute joins renewal before returning; renew must honor its context.