compute

package
v0.3.24-build-testing-01 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AskForBidRequest

type AskForBidRequest struct {
	RoutingMetadata
	// Job specifies the job to be executed.
	Job model.Job
}

type AskForBidResponse

type AskForBidResponse struct {
	ExecutionMetadata
	Accepted bool
	Reason   string
}

type BaseEndpoint

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

Base implementation of Endpoint

func NewBaseEndpoint

func NewBaseEndpoint(params BaseEndpointParams) BaseEndpoint

func (BaseEndpoint) AskForBid

func (s BaseEndpoint) AskForBid(ctx context.Context, request AskForBidRequest) (AskForBidResponse, error)

func (BaseEndpoint) BidAccepted

func (BaseEndpoint) BidRejected

func (BaseEndpoint) CancelExecution

func (BaseEndpoint) GetNodeID

func (s BaseEndpoint) GetNodeID() string

func (BaseEndpoint) ResultAccepted

func (BaseEndpoint) ResultRejected

type BaseEndpointParams

type BaseEndpointParams struct {
	ID              string
	ExecutionStore  store.ExecutionStore
	UsageCalculator capacity.UsageCalculator
	BidStrategy     bidstrategy.BidStrategy
	Executor        Executor
}

type BaseExecutor

type BaseExecutor struct {
	ID string
	// contains filtered or unexported fields
}

BaseExecutor is the base implementation for backend service. All operations are executed asynchronously, and a callback is used to notify the caller of the result.

func NewBaseExecutor

func NewBaseExecutor(params BaseExecutorParams) *BaseExecutor

func (*BaseExecutor) Cancel

func (e *BaseExecutor) Cancel(ctx context.Context, execution store.Execution) (err error)

Cancel the execution.

func (*BaseExecutor) Publish

func (e *BaseExecutor) Publish(ctx context.Context, execution store.Execution) (err error)

Publish the result of an execution after it has been verified.

func (*BaseExecutor) Run

func (e *BaseExecutor) Run(ctx context.Context, execution store.Execution) (err error)

Run the execution after it has been accepted, and propose a result to the requester to be verified.

type BaseExecutorParams

type BaseExecutorParams struct {
	ID              string
	Callback        Callback
	Store           store.ExecutionStore
	Executors       executor.ExecutorProvider
	Verifiers       verifier.VerifierProvider
	Publishers      publisher.PublisherProvider
	SimulatorConfig model.SimulatorConfigCompute
}

type BidAcceptedRequest

type BidAcceptedRequest struct {
	RoutingMetadata
	ExecutionID   string
	Accepted      bool
	Justification string
}

type BidAcceptedResponse

type BidAcceptedResponse struct {
	ExecutionMetadata
}

type BidRejectedRequest

type BidRejectedRequest struct {
	RoutingMetadata
	ExecutionID   string
	Justification string
}

type BidRejectedResponse

type BidRejectedResponse struct {
	ExecutionMetadata
}

type Callback

type Callback interface {
	OnRunComplete(ctx context.Context, result RunResult)
	OnPublishComplete(ctx context.Context, result PublishResult)
	OnCancelComplete(ctx context.Context, result CancelResult)
	OnComputeFailure(ctx context.Context, err ComputeError)
}

Callback Callbacks are used to notify the caller of the result of a job execution.

type CancelExecutionRequest

type CancelExecutionRequest struct {
	RoutingMetadata
	ExecutionID   string
	Justification string
}

type CancelExecutionResponse

type CancelExecutionResponse struct {
	ExecutionMetadata
}

type CancelResult

type CancelResult struct {
	RoutingMetadata
	ExecutionMetadata
}

CancelResult Result of a job cancel that is returned to the caller through a Callback.

type ChainedCallback

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

ChainedCallback Callback that chains multiple callbacks and delegates the calls to them.

func NewChainedCallback

func NewChainedCallback(params ChainedCallbackParams) *ChainedCallback

func (ChainedCallback) OnCancelComplete

func (c ChainedCallback) OnCancelComplete(ctx context.Context, result CancelResult)

func (ChainedCallback) OnComputeFailure

func (c ChainedCallback) OnComputeFailure(ctx context.Context, err ComputeError)

func (ChainedCallback) OnPublishComplete

func (c ChainedCallback) OnPublishComplete(ctx context.Context, result PublishResult)

func (ChainedCallback) OnRunComplete

func (c ChainedCallback) OnRunComplete(ctx context.Context, result RunResult)

type ChainedCallbackParams

type ChainedCallbackParams struct {
	Callbacks []Callback
}

type ComputeError

type ComputeError struct {
	RoutingMetadata
	ExecutionMetadata
	Err string
}

func (ComputeError) Error

func (e ComputeError) Error() string

type Endpoint

type Endpoint interface {
	// AskForBid asks for a bid for a given job, which will assign executionID to the job and return a bid
	// is interested in bidding on.
	AskForBid(context.Context, AskForBidRequest) (AskForBidResponse, error)
	// BidAccepted accepts a bid for a given executionID, which will trigger executing the job in the backend.
	// The execution can be synchronous or asynchronous, depending on the backend implementation.
	BidAccepted(context.Context, BidAcceptedRequest) (BidAcceptedResponse, error)
	// BidRejected rejects a bid for a given executionID.
	BidRejected(context.Context, BidRejectedRequest) (BidRejectedResponse, error)
	// ResultAccepted accepts a result for a given executionID, which will trigger publishing the result to the
	// destination specified in the job.
	ResultAccepted(context.Context, ResultAcceptedRequest) (ResultAcceptedResponse, error)
	// ResultRejected rejects a result for a given executionID.
	ResultRejected(context.Context, ResultRejectedRequest) (ResultRejectedResponse, error)
	// CancelExecution cancels a job for a given executionID.
	CancelExecution(context.Context, CancelExecutionRequest) (CancelExecutionResponse, error)
}

Endpoint is the frontend and entry point to the compute node. Requesters, whether through API, CLI or other means, do interact with the frontend service to submit jobs, ask for bids, accept or reject bids, etc.

type ExecutionMetadata

type ExecutionMetadata struct {
	ExecutionID string
	JobID       string
}

func NewExecutionMetadata

func NewExecutionMetadata(execution store.Execution) ExecutionMetadata

type Executor

type Executor interface {
	// Run triggers the execution of a job.
	Run(ctx context.Context, execution store.Execution) error
	// Publish publishes the result of a job execution.
	Publish(ctx context.Context, execution store.Execution) error
	// Cancel cancels the execution of a job.
	Cancel(ctx context.Context, execution store.Execution) error
}

Executor Backend service that is responsible for running and publishing executions. Implementations can be synchronous or asynchronous by using Callbacks.

type ExecutorBuffer

type ExecutorBuffer struct {
	ID string
	// contains filtered or unexported fields
}

ExecutorBuffer is a backend.Executor implementation that buffers executions locally until enough capacity is available to be able to run them. The buffer accepts a delegate backend.Executor that will be used to run the jobs. The buffer is implemented as a FIFO queue, where the order of the executions is determined by the order in which they were enqueued. However, an execution with high resource usage requirements might be skipped if there are newer jobs with lower resource usage requirements that can be executed immediately. This is done to improve utilization of compute nodes, though it might result in starvation and should be re-evaluated in the future.

func NewExecutorBuffer

func NewExecutorBuffer(params ExecutorBufferParams) *ExecutorBuffer

func (*ExecutorBuffer) Cancel

func (s *ExecutorBuffer) Cancel(_ context.Context, execution store.Execution) error

func (*ExecutorBuffer) EnqueuedExecutions

func (s *ExecutorBuffer) EnqueuedExecutions() []store.Execution

EnqueuedExecutions return list of enqueued executions

func (*ExecutorBuffer) Publish

func (s *ExecutorBuffer) Publish(_ context.Context, execution store.Execution) error

func (*ExecutorBuffer) Run

func (s *ExecutorBuffer) Run(ctx context.Context, execution store.Execution) (err error)

Run enqueues the execution and tries to run it if there is enough capacity.

func (*ExecutorBuffer) RunningExecutions

func (s *ExecutorBuffer) RunningExecutions() []store.Execution

RunningExecutions return list of running executions

type ExecutorBufferParams

type ExecutorBufferParams struct {
	ID                         string
	DelegateExecutor           Executor
	Callback                   Callback
	RunningCapacityTracker     capacity.Tracker
	EnqueuedCapacityTracker    capacity.Tracker
	DefaultJobExecutionTimeout time.Duration
	BackoffDuration            time.Duration
}

type NodeInfoProvider

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

func NewNodeInfoProvider

func NewNodeInfoProvider(params NodeInfoProviderParams) *NodeInfoProvider

func (*NodeInfoProvider) GetComputeInfo

func (n *NodeInfoProvider) GetComputeInfo(ctx context.Context) model.ComputeNodeInfo

type NodeInfoProviderParams

type NodeInfoProviderParams struct {
	Executors          executor.ExecutorProvider
	CapacityTracker    capacity.Tracker
	ExecutorBuffer     *ExecutorBuffer
	MaxJobRequirements model.ResourceUsageData
}

type PublishResult

type PublishResult struct {
	RoutingMetadata
	ExecutionMetadata
	PublishResult model.StorageSpec
}

PublishResult Result of a job publish that is returned to the caller through a Callback.

type ResultAcceptedRequest

type ResultAcceptedRequest struct {
	RoutingMetadata
	ExecutionID string
}

type ResultAcceptedResponse

type ResultAcceptedResponse struct {
	ExecutionMetadata
}

type ResultRejectedRequest

type ResultRejectedRequest struct {
	RoutingMetadata
	ExecutionID   string
	Justification string
}

type ResultRejectedResponse

type ResultRejectedResponse struct {
	ExecutionMetadata
}

type RoutingMetadata

type RoutingMetadata struct {
	SourcePeerID string
	TargetPeerID string
}

type RunResult

type RunResult struct {
	RoutingMetadata
	ExecutionMetadata
	ResultProposal   []byte
	RunCommandResult *model.RunCommandResult
}

RunResult Result of a job execution that is returned to the caller through a Callback.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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