requester

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const OverAskForBidsFactor = 3 // ask up to 3 times the desired number of bids

Variables

This section is empty.

Functions

This section is empty.

Types

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) CancelJob

func (node *BaseEndpoint) CancelJob(ctx context.Context, request CancelJobRequest) (CancelJobResult, error)

func (*BaseEndpoint) SubmitJob

func (node *BaseEndpoint) SubmitJob(ctx context.Context, data model.JobCreatePayload) (*model.Job, error)

type BaseEndpointParams

type BaseEndpointParams struct {
	ID                         string
	PublicKey                  []byte
	Scheduler                  *Scheduler
	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)
	// 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 added in v0.3.21

type ErrJobAlreadyTerminal struct {
	JobID string
}

func NewErrJobAlreadyTerminal added in v0.3.21

func NewErrJobAlreadyTerminal(jobID string) ErrJobAlreadyTerminal

func (ErrJobAlreadyTerminal) Error added in v0.3.21

func (e ErrJobAlreadyTerminal) Error() string

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

func (ErrNodeNotFound) Error

func (e ErrNodeNotFound) Error() string

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

func (ErrNotEnoughNodes) Error

func (e ErrNotEnoughNodes) Error() string

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.AskForBidShardResponse)

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 added in v0.3.20

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

func NewHousekeeping added in v0.3.20

func NewHousekeeping(params HousekeepingParams) *Housekeeping

func (*Housekeeping) Stop added in v0.3.20

func (h *Housekeeping) Stop()

type HousekeepingParams added in v0.3.20

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 Scheduler

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

func NewScheduler

func NewScheduler(params SchedulerParams) *Scheduler

func (*Scheduler) CancelJob added in v0.3.20

func (s *Scheduler) CancelJob(ctx context.Context, request CancelJobRequest) (CancelJobResult, error)

func (*Scheduler) OnCancelComplete

func (s *Scheduler) OnCancelComplete(ctx context.Context, result compute.CancelResult)

func (*Scheduler) OnComputeFailure

func (s *Scheduler) OnComputeFailure(ctx context.Context, result compute.ComputeError)

func (*Scheduler) OnPublishComplete

func (s *Scheduler) OnPublishComplete(ctx context.Context, result compute.PublishResult)

func (*Scheduler) OnRunComplete

func (s *Scheduler) OnRunComplete(ctx context.Context, result compute.RunResult)

func (*Scheduler) StartJob

func (s *Scheduler) StartJob(ctx context.Context, req StartJobRequest) error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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