Documentation
¶
Index ¶
- Constants
- func NewScheduler(params SchedulerParams) *scheduler
- type ApproveJobRequest
- type BaseEndpoint
- func (node *BaseEndpoint) ApproveJob(ctx context.Context, approval ApproveJobRequest) error
- func (node *BaseEndpoint) CancelJob(ctx context.Context, request CancelJobRequest) (CancelJobResult, error)
- func (node *BaseEndpoint) SubmitJob(ctx context.Context, data model.JobCreatePayload) (*model.Job, error)
- type BaseEndpointParams
- type CancelJobRequest
- type CancelJobResult
- type Endpoint
- type ErrJobAlreadyTerminal
- type ErrNodeNotFound
- type ErrNotEnoughNodes
- type EventEmitter
- func (e EventEmitter) EmitBidAccepted(ctx context.Context, request compute.BidAcceptedRequest, ...)
- func (e EventEmitter) EmitBidReceived(ctx context.Context, request compute.AskForBidRequest, ...)
- func (e EventEmitter) EmitBidRejected(ctx context.Context, request compute.BidRejectedRequest, ...)
- func (e EventEmitter) EmitComputeFailure(ctx context.Context, response compute.ComputeError)
- func (e EventEmitter) EmitEvent(ctx context.Context, event model.JobEvent) error
- func (e EventEmitter) EmitEventSilently(ctx context.Context, event model.JobEvent)
- func (e EventEmitter) EmitJobCreated(ctx context.Context, job model.Job)
- func (e EventEmitter) EmitPublishComplete(ctx context.Context, response compute.PublishResult)
- func (e EventEmitter) EmitResultAccepted(ctx context.Context, request compute.ResultAcceptedRequest, ...)
- func (e EventEmitter) EmitResultRejected(ctx context.Context, request compute.ResultRejectedRequest, ...)
- func (e EventEmitter) EmitRunComplete(ctx context.Context, response compute.RunResult)
- type EventEmitterParams
- type Housekeeping
- type HousekeepingParams
- type NodeDiscoverer
- type NodeRank
- type NodeRanker
- type Queue
- type Scheduler
- type SchedulerParams
- type StartJobRequest
Constants ¶
const OverAskForBidsFactor = 3 // ask up to 3 times the desired number of bids
Variables ¶
This section is empty.
Functions ¶
func NewScheduler ¶
func NewScheduler(params SchedulerParams) *scheduler
Types ¶
type ApproveJobRequest ¶ added in v0.3.24
type ApproveJobRequest struct {
ClientID string
JobID string
Response bidstrategy.BidStrategyResponse
}
type BaseEndpoint ¶
type BaseEndpoint struct {
// contains filtered or unexported fields
}
BaseEndpoint base implementation of requester Endpoint
func NewBaseEndpoint ¶
func NewBaseEndpoint(params *BaseEndpointParams) *BaseEndpoint
func (*BaseEndpoint) ApproveJob ¶ added in v0.3.24
func (node *BaseEndpoint) ApproveJob(ctx context.Context, approval ApproveJobRequest) error
type BaseEndpointParams ¶
type BaseEndpointParams struct {
ID string
PublicKey []byte
Scheduler Scheduler
Selector bidstrategy.BidStrategy
Store jobstore.Store
Verifiers verifier.VerifierProvider
StorageProviders storage.StorageProvider
MinJobExecutionTimeout time.Duration
DefaultJobExecutionTimeout time.Duration
}
type CancelJobRequest ¶
type CancelJobRequest struct {
JobID string
Reason string
UserTriggered bool
}
type CancelJobResult ¶
type CancelJobResult struct{}
type Endpoint ¶
type Endpoint interface {
// SubmitJob submits a new job to the network.
SubmitJob(context.Context, model.JobCreatePayload) (*model.Job, error)
// ApproveJob approves or rejects the running of a job.
ApproveJob(context.Context, ApproveJobRequest) error
// CancelJob cancels an existing job.
CancelJob(context.Context, CancelJobRequest) (CancelJobResult, error)
}
Endpoint is the frontend and entry point to the requester node for the end users to submit, update and cancel jobs.
type ErrJobAlreadyTerminal ¶
type ErrJobAlreadyTerminal struct {
JobID string
}
func NewErrJobAlreadyTerminal ¶
func NewErrJobAlreadyTerminal(jobID string) ErrJobAlreadyTerminal
type ErrNodeNotFound ¶
type ErrNodeNotFound struct {
// contains filtered or unexported fields
}
ErrNodeNotFound is returned when nodeInfo was not found for a requested peer id
func NewErrNodeNotFound ¶
func NewErrNodeNotFound(peerID peer.ID) ErrNodeNotFound
type ErrNotEnoughNodes ¶
type ErrNotEnoughNodes struct {
RequestedNodes int
AvailableNodes int
}
ErrNotEnoughNodes is returned when not enough nodes in the network to run a job
func NewErrNotEnoughNodes ¶
func NewErrNotEnoughNodes(requestedNodes, availableNodes int) ErrNotEnoughNodes
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
func NewEventEmitter ¶
func NewEventEmitter(params EventEmitterParams) EventEmitter
func (EventEmitter) EmitBidAccepted ¶
func (e EventEmitter) EmitBidAccepted(
ctx context.Context, request compute.BidAcceptedRequest, response compute.BidAcceptedResponse)
func (EventEmitter) EmitBidReceived ¶
func (e EventEmitter) EmitBidReceived(
ctx context.Context, request compute.AskForBidRequest, response compute.AskForBidResponse)
func (EventEmitter) EmitBidRejected ¶
func (e EventEmitter) EmitBidRejected(
ctx context.Context, request compute.BidRejectedRequest, response compute.BidRejectedResponse)
func (EventEmitter) EmitComputeFailure ¶
func (e EventEmitter) EmitComputeFailure(ctx context.Context, response compute.ComputeError)
func (EventEmitter) EmitEvent ¶
func (e EventEmitter) EmitEvent(ctx context.Context, event model.JobEvent) error
func (EventEmitter) EmitEventSilently ¶
func (e EventEmitter) EmitEventSilently(ctx context.Context, event model.JobEvent)
func (EventEmitter) EmitJobCreated ¶
func (e EventEmitter) EmitJobCreated(
ctx context.Context, job model.Job)
func (EventEmitter) EmitPublishComplete ¶
func (e EventEmitter) EmitPublishComplete(ctx context.Context, response compute.PublishResult)
func (EventEmitter) EmitResultAccepted ¶
func (e EventEmitter) EmitResultAccepted(
ctx context.Context, request compute.ResultAcceptedRequest, response compute.ResultAcceptedResponse)
func (EventEmitter) EmitResultRejected ¶
func (e EventEmitter) EmitResultRejected(
ctx context.Context, request compute.ResultRejectedRequest, response compute.ResultRejectedResponse)
func (EventEmitter) EmitRunComplete ¶
func (e EventEmitter) EmitRunComplete(ctx context.Context, response compute.RunResult)
type EventEmitterParams ¶
type EventEmitterParams struct {
EventConsumer eventhandler.JobEventHandler
}
A quick workaround to publish job events locally as we still have some types that rely on job events to update their states (e.g. localdb) and to take actions (e.g. websockets and logging) TODO: create a strongly typed local event emitter similar to libp2p event bus, and update localdb directly from
requester instead of consuming events.
type Housekeeping ¶
type Housekeeping struct {
// contains filtered or unexported fields
}
func NewHousekeeping ¶
func NewHousekeeping(params HousekeepingParams) *Housekeeping
type HousekeepingParams ¶
type HousekeepingParams struct {
Endpoint Endpoint
JobStore jobstore.Store
NodeID string
Interval time.Duration
}
type NodeDiscoverer ¶
type NodeDiscoverer interface {
FindNodes(ctx context.Context, job model.Job) ([]model.NodeInfo, error)
}
NodeDiscoverer discovers nodes in the network that are suitable to execute a job.
type NodeRank ¶
type NodeRank struct {
NodeInfo model.NodeInfo
Rank int
}
NodeRank represents a node and its rank. The higher the rank, the more preferable a node is to execute the job. A negative rank means the node is not suitable to execute the job.
type NodeRanker ¶
type NodeRanker interface {
RankNodes(ctx context.Context, job model.Job, nodes []model.NodeInfo) ([]NodeRank, error)
}
NodeRanker ranks nodes based on their suitability to execute a job.
type Queue ¶ added in v0.3.24
type Queue interface {
Scheduler
EnqueueJob(context.Context, model.Job) error
}
type Scheduler ¶
type Scheduler interface {
StartJob(context.Context, StartJobRequest) error
CancelJob(context.Context, CancelJobRequest) (CancelJobResult, error)
}
Scheduler distributes jobs to the compute nodes and tracks the executions.
type SchedulerParams ¶
type SchedulerParams struct {
ID string
Host host.Host
JobStore jobstore.Store
NodeDiscoverer NodeDiscoverer
NodeRanker NodeRanker
ComputeEndpoint compute.Endpoint
Verifiers verifier.VerifierProvider
StorageProviders storage.StorageProvider
EventEmitter EventEmitter
}
type StartJobRequest ¶
type StartJobRequest struct {
Job model.Job
}
StartJobRequest triggers the scheduling of a job.