workflow

package
v1.32.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT, MIT Imports: 28 Imported by: 0

Documentation

Overview

Package workflow contains the actual workflow of a worker controller instance

Index

Constants

View Source
const (
	ValidateSpecActivityTimeout                  = 15 * time.Second
	PullStatsActivityTimeout                     = 60 * time.Second
	HandleTaskAddSignalActivityTimeout           = 15 * time.Second
	HandleDeferredScalingDecisionActivityTimeout = 15 * time.Second
	InvokeWorkerActivityTimeout                  = 2 * time.Minute
	UpdateWorkerSetSizeActivityTimeout           = 2 * time.Minute
	RegisterTaskQueuesViaWorkersActivityTimeout  = 30 * time.Second
)

Variables

This section is empty.

Functions

func Workflow

func Workflow(ctx workflow.Context, unsafeWorkflowVersionGetter func() WorkerControllerInstanceWorkflowVersion, unsafeMaxVersion func() int, unsafePeriodicValidationInterval func() time.Duration, args *iface.WorkerControllerInstanceWorkflowArgs, activities *Activities) error

Workflow is implemented in a way such that it always CaNs after some history events are added to it and when it has no pending work to do. This is to keep the history clean so that we have less concern about backwards and forwards compatibility. In steady state (i.e. absence of ongoing updates or signals) the wf should only have a single wft in the history.

Types

type Activities

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

func NewActivities

func NewActivities(
	namespace *namespace.Namespace,
	dc *dynamicconfig.Collection,
	workflowserviceClient workflowservice.WorkflowServiceClient,
) *Activities

func (*Activities) InvokeWorker

func (a *Activities) InvokeWorker(ctx context.Context, req *InvokeWorkerActivityRequest) error

func (*Activities) PullStats

func (*Activities) UpdateWorkerSetSize

func (a *Activities) UpdateWorkerSetSize(ctx context.Context, req *UpdateWorkerSetSizeActivityRequest) error

func (*Activities) ValidateSpec

func (a *Activities) ValidateSpec(ctx context.Context, req *ValidateSpecRequest) error

type HandleDeferredScalingDecisionActivityRequest

type HandleDeferredScalingDecisionActivityRequest struct {
	RequestContext

	Request         iface.SignalTaskAddRequest `json:"request"`
	ScalingGroupKey string                     `json:"scaling_group_key"`

	ScalingGroupSpec   iface.ScalingGroupSpec       `json:"scaling_group_spec"`
	EffectiveTaskTypes []enumspb.TaskQueueType      `json:"effective_task_types"`
	ScalingStatus      iface.ScalingAlgorithmStatus `json:"scaling_status"`
}

type HandleDeferredScalingDecisionActivityResponse

type HandleDeferredScalingDecisionActivityResponse struct {
	UpdatedScalingStatus iface.ScalingAlgorithmStatus     `json:"scaling_status"`
	Actions              []scalingalgorithm.ScalingAction `json:"actions,omitempty"`
}

type HandleTaskAddSignalActivityRequest

type HandleTaskAddSignalActivityRequest struct {
	RequestContext

	Request iface.SignalTaskAddRequest `json:"request"`

	Spec          *iface.WorkerControllerInstanceSpec     `json:"spec"`
	ScalingStatus map[string]iface.ScalingAlgorithmStatus `json:"scaling_status"`
}

type HandleTaskAddSignalActivityResponse

type HandleTaskAddSignalActivityResponse struct {
	UpdatedScalingStatus map[string]iface.ScalingAlgorithmStatus `json:"scaling_status"`
	Actions              []scalingalgorithm.ScalingAction        `json:"actions,omitempty"`
}

type InvokeWorkerActivityRequest

type InvokeWorkerActivityRequest struct {
	RequestContext

	ComputeConfig *iface.ComputeProviderSpec `json:"compute_config"`
}

type InvokeWorkersToRegisterTaskQueuesRequest

type InvokeWorkersToRegisterTaskQueuesRequest struct {
	RequestContext
	iface.WorkerControllerInstanceSpec

	// ScalingStatus is the per-group scaling status, used to size a worker-set
	// registration resize to the algorithm's planned count.
	ScalingStatus map[string]iface.ScalingAlgorithmStatus `json:"scaling_status,omitempty"`
}

type InvokeWorkersToRegisterTaskQueuesResponse

type InvokeWorkersToRegisterTaskQueuesResponse struct {
	// UpdatedScalingStatus is the complete next-state scaling status for every group in
	// the spec: resized groups carry their reconciled count, skipped (already-registered)
	// groups carry their prior status forward. The workflow assigns it wholesale.
	UpdatedScalingStatus map[string]iface.ScalingAlgorithmStatus `json:"scaling_status,omitempty"`
}

type PullStatsActivityRequest

type PullStatsActivityRequest struct {
	RequestContext

	Spec          *iface.WorkerControllerInstanceSpec     `json:"spec"`
	ScalingStatus map[string]iface.ScalingAlgorithmStatus `json:"scaling_status"`
}

type PullStatsActivityResponse

type PullStatsActivityResponse struct {
	UpdatedScalingStatus map[string]iface.ScalingAlgorithmStatus `json:"scaling_status"`
	Actions              []scalingalgorithm.ScalingAction        `json:"actions,omitempty"`
	NextPollSeconds      uint32                                  `json:"next_poll_seconds"`
}

type RequestContext

type RequestContext = computeprovider.RequestContext

RequestContext aliases the compute-provider request context so activity request types can embed it while compute providers consume the same type directly. The alias keeps it defined in compute_provider (which the ComputeProvider interface depends on) without an import cycle.

type SignalHandler

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

SignalHandler encapsulates the signal handling logic

type UpdateWorkerSetSizeActivityRequest

type UpdateWorkerSetSizeActivityRequest struct {
	RequestContext

	ComputeConfig *iface.ComputeProviderSpec `json:"compute_config"`
	UpdatedSize   int32                      `json:"updated_size"`
}

type ValidateSpecRequest

type ValidateSpecRequest struct {
	RequestContext

	Spec *iface.WorkerControllerInstanceSpec `json:"spec"`
}

type WorkerControllerInstanceWorkflowVersion

type WorkerControllerInstanceWorkflowVersion int64
const (

	// Represents the very first version of the workflow
	InitialVersion WorkerControllerInstanceWorkflowVersion = iota

	// Adds periodic background re-validation of the spec. The timer fires every
	// periodic validation interval (default 6h; configurable via dynamic config).
	PeriodicValidationVersion

	// Signals the version workflow after each ValidationStatus change so the
	// deployment workflow can maintain an aggregate connectivity summary in its memo.
	SignalVersionWorkflowVersion

	// Cancels the child context which is attached to the timer futures,
	// which, on deletion, will mark the future as failed and prevent the body of
	// the associated callback from running.
	CancelTimersOnDeleteVersion
)

type WorkflowRunner

type WorkflowRunner struct {
	*iface.WorkerControllerInstanceWorkflowArgs
	// contains filtered or unexported fields
}

WorkflowRunner holds the local state while running a worker controller workflow

Directories

Path Synopsis
Package computeprovider contains the implementations of the various compute providers
Package computeprovider contains the implementations of the various compute providers
Package iface contains the interface definitions to interact with the WCI workflows these are internal to the project.
Package iface contains the interface definitions to interact with the WCI workflows these are internal to the project.
Package scalingalgorithm contains the different scaling algorithms available for WCIs
Package scalingalgorithm contains the different scaling algorithms available for WCIs

Jump to

Keyboard shortcuts

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