Help us shape the future of Go! Take the 2026 Go Developer Survey

forge_worker

package
v0.57.29 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const WorkerCreateOpTypeID = "forge/worker/create"

WorkerCreateOpTypeID is the type ID of WorkerCreateOp.

View Source
const WorkerTypeID = "forge/worker"

WorkerTypeID is the type ID of Worker.

Variables

View Source
var WorkerTypes = []typeid.Type{
	{ID: WorkerTypeID, New: func() any { return new(Worker) }},
	{ID: WorkerCreateOpTypeID, New: func() any { return new(WorkerCreateOp) }},
}

WorkerTypes lists the typed messages of worker.proto.

Functions

func CheckWorkerType

func CheckWorkerType(ctx context.Context, ws world.WorldState, objKey string) error

CheckWorkerType checks the type graph quad for a worker.

func CollectWorkerKeypairs

func CollectWorkerKeypairs(ctx context.Context, w world.WorldState, workerKeys ...string) ([]*identity.Keypair, []string, error)

CollectWorkerKeypairs collects all Keypair linked to by the given entities. returns list of Keypair for each object key

func CreateWorker

func CreateWorker(
	ctx context.Context,
	w world.WorldState,
	objKey string,
	name string,
	keypairs []*identity.Keypair,
	sender peer.ID,
) (uint64, bool, error)

CreateWorker stores a Worker in a object. Optionally creates keypairs linked to the Worker. Returns seqno, sysErr, error.

func ListWorkerKeypairs

func ListWorkerKeypairs(ctx context.Context, w world.WorldState, workerKeys ...string) ([]string, error)

ListWorkerKeypairs lists all Keypair linked to by the given Worker object keys. returns list of object keys

func ListWorkers

func ListWorkers(ctx context.Context, ws world.WorldState) ([]string, error)

ListWorkers lists all of the worker keys in the world.

func NewWorkerBlock

func NewWorkerBlock() block.Block

NewWorkerBlock constructs a new Worker block.

Types

type Placement

type Placement struct {

	// WorkerObjectKey is the selected Worker's World identity, retained as an immutable placement snapshot.
	WorkerObjectKey string `protobuf:"bytes,1,opt,name=worker_object_key,json=workerObjectKey,proto3" json:"workerObjectKey,omitempty"`
	// PeerId is the authenticated Device peer linked to that Worker when selected.
	PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
	// contains filtered or unexported fields
}

Placement freezes the selected Worker and authenticated Device peer for a Job attempt.

func (*Placement) CloneMessageVT

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

func (*Placement) CloneVT

func (m *Placement) CloneVT() *Placement

func (*Placement) EqualMessageVT

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

func (*Placement) EqualVT

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

func (*Placement) GetPeerId

func (x *Placement) GetPeerId() string

func (*Placement) GetWorkerObjectKey

func (x *Placement) GetWorkerObjectKey() string

func (*Placement) MarshalJSON

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

MarshalJSON marshals the Placement to JSON.

func (*Placement) MarshalProtoJSON

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

MarshalProtoJSON marshals the Placement message to JSON.

func (*Placement) MarshalProtoText

func (x *Placement) MarshalProtoText() string

func (*Placement) MarshalToSizedBufferVT

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

func (*Placement) MarshalToVT

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

func (*Placement) MarshalVT

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

func (*Placement) ProtoMessage

func (*Placement) ProtoMessage()

func (*Placement) Reset

func (x *Placement) Reset()

func (*Placement) SizeVT

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

func (*Placement) String

func (x *Placement) String() string

func (*Placement) UnmarshalJSON

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

UnmarshalJSON unmarshals the Placement from JSON.

func (*Placement) UnmarshalProtoJSON

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

UnmarshalProtoJSON unmarshals the Placement message from JSON.

func (*Placement) UnmarshalVT

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

func (*Placement) Validate

func (p *Placement) Validate() error

Validate checks that a placement names one Worker and one Device peer.

func (*Placement) ValidateLinked

func (p *Placement) ValidateLinked(ctx context.Context, ws world.WorldState) error

ValidateLinked checks that the selected peer belongs to the selected Worker.

type Worker

type Worker struct {

	// Name is the human readable worker name.
	// Example: "my-worker-1"
	// Must be a valid DNS label as defined in RFC 1123.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

Worker associates a set of keypairs with a worker name. The name is used for API calls and command-line / UI tools. The keypairs are load-balance assigned tasks to run by the scheduler. Worker automatically starts controllers for all assigned objects.

Graph links: - identity/keypair-link: links to Keypairs representing the Worker. Incoming links: - forge/cluster-worker: links from Cluster to Worker.

func LookupWorker

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

LookupWorker looks up a worker in the world.

func UnmarshalWorker

func UnmarshalWorker(ctx context.Context, bcs *block.Cursor) (*Worker, error)

UnmarshalWorker unmarshals a worker block from the cursor.

func (*Worker) CloneMessageVT

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

func (*Worker) CloneVT

func (m *Worker) CloneVT() *Worker

func (*Worker) EqualMessageVT

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

func (*Worker) EqualVT

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

func (*Worker) GetName

func (x *Worker) GetName() string

func (*Worker) MarshalJSON

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

MarshalJSON marshals the Worker to JSON.

func (*Worker) MarshalProtoJSON

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

MarshalProtoJSON marshals the Worker message to JSON.

func (*Worker) MarshalProtoText

func (x *Worker) MarshalProtoText() string

func (*Worker) MarshalToSizedBufferVT

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

func (*Worker) MarshalToVT

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

func (*Worker) MarshalVT

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

func (*Worker) ProtoMessage

func (*Worker) ProtoMessage()

func (*Worker) Reset

func (x *Worker) Reset()

func (*Worker) SizeVT

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

func (*Worker) String

func (x *Worker) String() string

func (*Worker) TypeID

func (*Worker) TypeID() string

TypeID returns the type ID of Worker.

func (*Worker) UnmarshalJSON

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

UnmarshalJSON unmarshals the Worker from JSON.

func (*Worker) UnmarshalProtoJSON

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

UnmarshalProtoJSON unmarshals the Worker message from JSON.

func (*Worker) UnmarshalVT

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

func (*Worker) Validate

func (e *Worker) Validate() error

Validate performs cursory checks of the Worker object.

type WorkerCreateOp

type WorkerCreateOp struct {

	// ObjectKey is the object key to create the Worker.
	ObjectKey string `protobuf:"bytes,1,opt,name=object_key,json=objectKey,proto3" json:"objectKey,omitempty"`
	// Name is the worker name to create.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Keypairs is the list of keypairs to add and/or link to the worker.
	// Must not have duplicates.
	// Optional.
	Keypairs []*identity.Keypair `protobuf:"bytes,3,rep,name=keypairs,proto3" json:"keypairs,omitempty"`
	// contains filtered or unexported fields
}

WorkerCreateOp creates a Worker.

func NewWorkerCreateOp

func NewWorkerCreateOp(objectKey, name string, keypairs []*identity.Keypair) *WorkerCreateOp

NewWorkerCreateOp constructs a new WorkerCreateOp block.

func (*WorkerCreateOp) ApplyWorldOp

func (o *WorkerCreateOp) ApplyWorldOp(
	ctx context.Context,
	le *logrus.Entry,
	worldHandle world.WorldState,
	sender peer.ID,
) (sysErr bool, err error)

ApplyWorldOp applies the operation as a world operation.

func (*WorkerCreateOp) BuildWorker

func (o *WorkerCreateOp) BuildWorker() *Worker

BuildWorker builds the worker object from the create op.

func (*WorkerCreateOp) CloneMessageVT

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

func (*WorkerCreateOp) CloneVT

func (m *WorkerCreateOp) CloneVT() *WorkerCreateOp

func (*WorkerCreateOp) EqualMessageVT

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

func (*WorkerCreateOp) EqualVT

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

func (*WorkerCreateOp) GetKeypairs

func (x *WorkerCreateOp) GetKeypairs() []*identity.Keypair

func (*WorkerCreateOp) GetName

func (x *WorkerCreateOp) GetName() string

func (*WorkerCreateOp) GetObjectKey

func (x *WorkerCreateOp) GetObjectKey() string

func (*WorkerCreateOp) MarshalJSON

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

MarshalJSON marshals the WorkerCreateOp to JSON.

func (*WorkerCreateOp) MarshalProtoJSON

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

MarshalProtoJSON marshals the WorkerCreateOp message to JSON.

func (*WorkerCreateOp) MarshalProtoText

func (x *WorkerCreateOp) MarshalProtoText() string

func (*WorkerCreateOp) MarshalToSizedBufferVT

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

func (*WorkerCreateOp) MarshalToVT

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

func (*WorkerCreateOp) MarshalVT

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

func (*WorkerCreateOp) ProtoMessage

func (*WorkerCreateOp) ProtoMessage()

func (*WorkerCreateOp) Reset

func (x *WorkerCreateOp) Reset()

func (*WorkerCreateOp) SizeVT

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

func (*WorkerCreateOp) String

func (x *WorkerCreateOp) String() string

func (*WorkerCreateOp) TypeID

func (*WorkerCreateOp) TypeID() string

TypeID returns the type ID of WorkerCreateOp.

func (*WorkerCreateOp) UnmarshalJSON

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

UnmarshalJSON unmarshals the WorkerCreateOp from JSON.

func (*WorkerCreateOp) UnmarshalProtoJSON

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

UnmarshalProtoJSON unmarshals the WorkerCreateOp message from JSON.

func (*WorkerCreateOp) UnmarshalVT

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

func (*WorkerCreateOp) Validate

func (o *WorkerCreateOp) Validate() error

Validate performs cursory validation of the operation. Should not block.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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