forge_execution

package
v0.51.6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExecutionTypeID is the type identifier for a Execution.
	ExecutionTypeID = "forge/execution"
)

Variables

View Source
var (
	State_name = map[int32]string{
		0: "ExecutionState_UNKNOWN",
		1: "ExecutionState_PENDING",
		2: "ExecutionState_RUNNING",
		3: "ExecutionState_COMPLETE",
	}
	State_value = map[string]int32{
		"ExecutionState_UNKNOWN":  0,
		"ExecutionState_PENDING":  1,
		"ExecutionState_RUNNING":  2,
		"ExecutionState_COMPLETE": 3,
	}
)

Enum value maps for State.

View Source
var ErrUnknownState = errors.New("unknown execution state")

ErrUnknownState is returned if the state was unknown.

Functions

func ComputeExecutionOutputs

func ComputeExecutionOutputs(
	outputs []*forge_target.Output,
	execOutputVals []forge_value.ValueSlice,
	allowFailed bool,
) ([]*forge_value.Value, error)

ComputeExecutionOutputs computes the result from a set of Executions. if allowFailed is set, any failed or invalid executions are skipped. if no valid executions are in the list, returns an error. If minComplete != 0 and len(valid execs) < minComplete, fails.

func CreateExecutionWithTarget

func CreateExecutionWithTarget(
	ctx context.Context,
	ws world.WorldState,
	sender peer.ID,
	objKey string,
	execPeerID peer.ID,
	valueSet *forge_target.ValueSet,
	tgt *forge_target.Target,
	ts *timestamp.Timestamp,
) (*bucket.ObjectRef, error)

CreateExecutionWithTarget creates a pending Execution object in the world.

Writes the Target to a block linked to by the Execution. peerID is the peer id to assign to the execution.

func NewExecutionBlock

func NewExecutionBlock() block.Block

NewExecutionBlock constructs a new Execution block.

Types

type Execution

type Execution struct {

	// ExecutionState is the current state of the execution.
	ExecutionState State `protobuf:"varint,1,opt,name=execution_state,json=executionState,proto3" json:"executionState,omitempty"`
	// PeerId is the identifier of the peer assigned to the execution.
	// Can be empty.
	PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
	// Timestamp is the time the parent object (usually Pass) was created.
	// Used as a reference timestamp to make all ops deterministic.
	// Must be set & is not updated.
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// ValueSet is the set of inputs and outputs used in the execution.
	// Outputs are updated while the execution is in RUNNING state.
	ValueSet *target.ValueSet `protobuf:"bytes,4,opt,name=value_set,json=valueSet,proto3" json:"valueSet,omitempty"`
	// TargetRef is the block ref to the Target block.
	TargetRef *block.BlockRef `protobuf:"bytes,5,opt,name=target_ref,json=targetRef,proto3" json:"targetRef,omitempty"`
	// Result is information about the outcome of a completed execution.
	Result *value.Result `protobuf:"bytes,6,opt,name=result,proto3" json:"result,omitempty"`
	// LogEntries contains log output from the execution.
	// Appended while the execution is in RUNNING state.
	LogEntries []*LogEntry `protobuf:"bytes,7,rep,name=log_entries,json=logEntries,proto3" json:"logEntries,omitempty"`
	// contains filtered or unexported fields
}

World graph links:

  • <parent> -> usually a Pass which created the Execution

func FilterExecutionOutputs

func FilterExecutionOutputs(execs []*Execution, allowFailed bool, minComplete int) ([]*Execution, [][]*forge_value.Value, error)

FilterExecutionOutputs returns only valid outputs for completed executions. if allowFailed, skips any failed or invalid executions.

func LookupExecution

func LookupExecution(ctx context.Context, ws world.WorldState, objKey string) (*Execution, world.ObjectState, error)

LookupExecution looks up an execution in the world.

func UnmarshalExecution

func UnmarshalExecution(ctx context.Context, bcs *block.Cursor) (*Execution, error)

UnmarshalExecution unmarshals an execution block from the cursor.

func WaitExecutionComplete

func WaitExecutionComplete(
	ctx context.Context,
	le *logrus.Entry,
	ws world.WorldState,
	executionObjectKey string,
) (*Execution, error)

WaitExecutionComplete waits until the execution is in the COMPLETE state.

func (*Execution) ApplyBlockRef

func (e *Execution) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*Execution) ApplySubBlock

func (e *Execution) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Execution) CheckPeerID

func (e *Execution) CheckPeerID(id peer.ID) error

CheckPeerID checks if the peer ID matches the Execution.

func (*Execution) CloneMessageVT

func (m *Execution) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Execution) CloneVT

func (m *Execution) CloneVT() *Execution

func (*Execution) EqualMessageVT

func (this *Execution) EqualMessageVT(thatMsg any) bool

func (*Execution) EqualVT

func (this *Execution) EqualVT(that *Execution) bool

func (*Execution) GetBlockRefCtor

func (e *Execution) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*Execution) GetBlockRefs

func (e *Execution) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*Execution) GetExecutionState

func (x *Execution) GetExecutionState() State

func (*Execution) GetLogEntries

func (x *Execution) GetLogEntries() []*LogEntry

func (*Execution) GetPeerId

func (x *Execution) GetPeerId() string

func (*Execution) GetResult

func (x *Execution) GetResult() *value.Result

func (*Execution) GetSubBlockCtor

func (e *Execution) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Execution) GetSubBlocks

func (e *Execution) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Execution) GetTargetRef

func (x *Execution) GetTargetRef() *block.BlockRef

func (*Execution) GetTimestamp

func (x *Execution) GetTimestamp() *timestamppb.Timestamp

func (*Execution) GetValueSet

func (x *Execution) GetValueSet() *target.ValueSet

func (*Execution) IsComplete

func (e *Execution) IsComplete() bool

IsComplete checks if the execution is in the COMPLETE state.

func (*Execution) MarshalBlock

func (e *Execution) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*Execution) MarshalJSON

func (x *Execution) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Execution to JSON.

func (*Execution) MarshalProtoJSON

func (x *Execution) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Execution message to JSON.

func (*Execution) MarshalProtoText

func (x *Execution) MarshalProtoText() string

func (*Execution) MarshalToSizedBufferVT

func (m *Execution) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Execution) MarshalToVT

func (m *Execution) MarshalToVT(dAtA []byte) (int, error)

func (*Execution) MarshalVT

func (m *Execution) MarshalVT() (dAtA []byte, err error)

func (*Execution) ParsePeerID

func (e *Execution) ParsePeerID() (peer.ID, error)

ParsePeerID parses the peer ID field. Returns empty if not set.

func (*Execution) ProtoMessage

func (*Execution) ProtoMessage()

func (*Execution) Reset

func (x *Execution) Reset()

func (*Execution) SizeVT

func (m *Execution) SizeVT() (n int)

func (*Execution) String

func (x *Execution) String() string

func (*Execution) UnmarshalBlock

func (e *Execution) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*Execution) UnmarshalJSON

func (x *Execution) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Execution from JSON.

func (*Execution) UnmarshalProtoJSON

func (x *Execution) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Execution message from JSON.

func (*Execution) UnmarshalVT

func (m *Execution) UnmarshalVT(dAtA []byte) error

func (*Execution) Validate

func (e *Execution) Validate() error

Validate performs cursory checks of the execution object.

type LogEntry

type LogEntry struct {

	// Timestamp is when the log entry was created.
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// Level is the log level (e.g. "info", "warn", "error", "debug").
	Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"`
	// Message is the log message text.
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

LogEntry is a single log line from an execution.

func (*LogEntry) CloneMessageVT

func (m *LogEntry) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*LogEntry) CloneVT

func (m *LogEntry) CloneVT() *LogEntry

func (*LogEntry) EqualMessageVT

func (this *LogEntry) EqualMessageVT(thatMsg any) bool

func (*LogEntry) EqualVT

func (this *LogEntry) EqualVT(that *LogEntry) bool

func (*LogEntry) GetLevel

func (x *LogEntry) GetLevel() string

func (*LogEntry) GetMessage

func (x *LogEntry) GetMessage() string

func (*LogEntry) GetTimestamp

func (x *LogEntry) GetTimestamp() *timestamppb.Timestamp

func (*LogEntry) MarshalJSON

func (x *LogEntry) MarshalJSON() ([]byte, error)

MarshalJSON marshals the LogEntry to JSON.

func (*LogEntry) MarshalProtoJSON

func (x *LogEntry) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the LogEntry message to JSON.

func (*LogEntry) MarshalProtoText

func (x *LogEntry) MarshalProtoText() string

func (*LogEntry) MarshalToSizedBufferVT

func (m *LogEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*LogEntry) MarshalToVT

func (m *LogEntry) MarshalToVT(dAtA []byte) (int, error)

func (*LogEntry) MarshalVT

func (m *LogEntry) MarshalVT() (dAtA []byte, err error)

func (*LogEntry) ProtoMessage

func (*LogEntry) ProtoMessage()

func (*LogEntry) Reset

func (x *LogEntry) Reset()

func (*LogEntry) SizeVT

func (m *LogEntry) SizeVT() (n int)

func (*LogEntry) String

func (x *LogEntry) String() string

func (*LogEntry) UnmarshalJSON

func (x *LogEntry) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the LogEntry from JSON.

func (*LogEntry) UnmarshalProtoJSON

func (x *LogEntry) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the LogEntry message from JSON.

func (*LogEntry) UnmarshalVT

func (m *LogEntry) UnmarshalVT(dAtA []byte) error

type Spec

type Spec struct {

	// PeerId is the identifier of the peer assigned to the execution.
	// Can be empty.
	PeerId string `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
	// ValueSet is the set of inputs and outputs used in the execution.
	// Specified output values are used as initial values, and can be overridden.
	ValueSet *target.ValueSet `protobuf:"bytes,2,opt,name=value_set,json=valueSet,proto3" json:"valueSet,omitempty"`
	// TargetRef is the target to run in the Execution.
	// Overrides "target" field if set.
	TargetRef *block.BlockRef `protobuf:"bytes,3,opt,name=target_ref,json=targetRef,proto3" json:"targetRef,omitempty"`
	// contains filtered or unexported fields
}

Spec contains information specified when creating a Execution.

func NewSpec

func NewSpec(
	peerID peer.ID,
	targetRef *block.BlockRef,
	valueSet *forge_target.ValueSet,
) *Spec

NewSpec constructs a execution specification with parameters.

peerID can be empty.

func (*Spec) ApplyBlockRef

func (s *Spec) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id.

func (*Spec) ApplySubBlock

func (s *Spec) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Spec) AssignTarget

func (s *Spec) AssignTarget(bcs *block.Cursor, tgt *forge_target.Target)

AssignTarget assigns a target to the spec with a block cursor. if tgt is nil clears the field

func (*Spec) CloneMessageVT

func (m *Spec) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Spec) CloneVT

func (m *Spec) CloneVT() *Spec

func (*Spec) EqualMessageVT

func (this *Spec) EqualMessageVT(thatMsg any) bool

func (*Spec) EqualVT

func (this *Spec) EqualVT(that *Spec) bool

func (*Spec) GetBlockRefCtor

func (s *Spec) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id.

func (*Spec) GetBlockRefs

func (s *Spec) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID.

func (*Spec) GetPeerId

func (x *Spec) GetPeerId() string

func (*Spec) GetSubBlockCtor

func (s *Spec) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Spec) GetSubBlocks

func (s *Spec) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Spec) GetTargetRef

func (x *Spec) GetTargetRef() *block.BlockRef

func (*Spec) GetValueSet

func (x *Spec) GetValueSet() *target.ValueSet

func (*Spec) MarshalBlock

func (s *Spec) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary.

func (*Spec) MarshalJSON

func (x *Spec) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Spec to JSON.

func (*Spec) MarshalProtoJSON

func (x *Spec) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Spec message to JSON.

func (*Spec) MarshalProtoText

func (x *Spec) MarshalProtoText() string

func (*Spec) MarshalToSizedBufferVT

func (m *Spec) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Spec) MarshalToVT

func (m *Spec) MarshalToVT(dAtA []byte) (int, error)

func (*Spec) MarshalVT

func (m *Spec) MarshalVT() (dAtA []byte, err error)

func (*Spec) ProtoMessage

func (*Spec) ProtoMessage()

func (*Spec) Reset

func (x *Spec) Reset()

func (*Spec) SizeVT

func (m *Spec) SizeVT() (n int)

func (*Spec) String

func (x *Spec) String() string

func (*Spec) UnmarshalBlock

func (s *Spec) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object.

func (*Spec) UnmarshalJSON

func (x *Spec) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Spec from JSON.

func (*Spec) UnmarshalProtoJSON

func (x *Spec) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Spec message from JSON.

func (*Spec) UnmarshalVT

func (m *Spec) UnmarshalVT(dAtA []byte) error

type State

type State int32

State contains the possible execution states.

const (
	// ExecutionState_UNKNOWN is the unknown type.
	State_ExecutionState_UNKNOWN State = 0
	// ExecutionState_PENDING is the state before the execution starts.
	// Transitions to RUNNING when the assigned peer acks exec start.
	State_ExecutionState_PENDING State = 1
	// ExecutionState_RUNNING is the state when the execution is running.
	State_ExecutionState_RUNNING State = 2
	// ExecutionState_COMPLETE is the terminal state of the execution.
	// This includes both success and failure termination states.
	State_ExecutionState_COMPLETE State = 3
)

func (State) EnsureMatches

func (s State) EnsureMatches(sts ...State) error

EnsureMatches checks if the state matches or returns an error.

func (State) Enum

func (x State) Enum() *State

func (State) MarshalJSON

func (x State) MarshalJSON() ([]byte, error)

MarshalJSON marshals the State to JSON.

func (State) MarshalProtoJSON

func (x State) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the State to JSON.

func (State) MarshalProtoText

func (x State) MarshalProtoText() string

func (State) MarshalText

func (x State) MarshalText() ([]byte, error)

MarshalText marshals the State to text.

func (State) String

func (x State) String() string

func (*State) UnmarshalJSON

func (x *State) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the State from JSON.

func (*State) UnmarshalProtoJSON

func (x *State) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the State from JSON.

func (*State) UnmarshalText

func (x *State) UnmarshalText(b []byte) error

UnmarshalText unmarshals the State from text.

func (State) Validate

func (s State) Validate(allowUnknown bool) error

Validate checks the execution state is within known values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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