localdb

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructJobFromEvent added in v0.3.20

func ConstructJobFromEvent(ev model.JobEvent) *model.Job

func FlattenShardStates added in v0.3.20

func FlattenShardStates(jobState model.JobState) []model.JobShardState

func GetCompletedVerifiedShardStates added in v0.3.20

func GetCompletedVerifiedShardStates(jobState model.JobState) []model.JobShardState

return only shard states that are both complete and verified

func GetFilteredShardStates added in v0.3.20

func GetFilteredShardStates(jobState model.JobState, filterState model.JobStateType) []model.JobShardState

Types

type JobLoader added in v0.3.20

type JobLoader func(ctx context.Context, id string) (*model.Job, error)

type JobQuery

type JobQuery struct {
	ID          string              `json:"id"`
	ClientID    string              `json:"clientID"`
	IncludeTags []model.IncludedTag `json:"include_tags"`
	ExcludeTags []model.ExcludedTag `json:"exclude_tags"`
	Limit       int                 `json:"limit"`
	Offset      int                 `json:"offset"`
	ReturnAll   bool                `json:"return_all"`
	SortBy      string              `json:"sort_by"`
	SortReverse bool                `json:"sort_reverse"`
}

type LocalDB

type LocalDB interface {
	GetJob(ctx context.Context, id string) (*model.Job, error)
	GetJobState(ctx context.Context, jobID string) (model.JobState, error)
	GetJobEvents(ctx context.Context, id string) ([]model.JobEvent, error)
	GetJobLocalEvents(ctx context.Context, id string) ([]model.JobLocalEvent, error)
	GetJobs(ctx context.Context, query JobQuery) ([]*model.Job, error)
	GetJobsCount(ctx context.Context, query JobQuery) (int, error)
	HasLocalEvent(ctx context.Context, jobID string, eventFilter LocalEventFilter) (bool, error)
	AddJob(ctx context.Context, j *model.Job) error
	AddEvent(ctx context.Context, jobID string, event model.JobEvent) error
	AddLocalEvent(ctx context.Context, jobID string, event model.JobLocalEvent) error
	UpdateJobDeal(ctx context.Context, jobID string, deal model.Deal) error
	UpdateShardState(
		ctx context.Context,
		jobID, nodeID string,
		shardIndex int,
		state model.JobShardState,
	) error
}

A LocalDB will persist jobs and their state to the underlying storage. It also gives an efficient way to retrieve jobs using queries. The LocalDB is the local view of the world and the transport will get events to other nodes that will update their datastore.

The LocalDB and Transport interfaces could be swapped out for some kind of smart contract implementation (e.g. FVM)

type LocalDBEventHandler

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

An event handler that listens to both job and local events, and updates the LocalDB instance accordingly

func NewLocalDBEventHandler

func NewLocalDBEventHandler(localDB LocalDB) *LocalDBEventHandler

func (*LocalDBEventHandler) HandleJobEvent

func (h *LocalDBEventHandler) HandleJobEvent(ctx context.Context, event model.JobEvent) error

func (*LocalDBEventHandler) HandleLocalEvent

func (h *LocalDBEventHandler) HandleLocalEvent(ctx context.Context, event model.JobLocalEvent) error

type LocalEventFilter

type LocalEventFilter func(ev model.JobLocalEvent) bool

type StateLoader added in v0.3.20

type StateLoader func(ctx context.Context, id string) (model.JobState, error)

type StateResolver added in v0.3.20

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

func GetStateResolver

func GetStateResolver(db LocalDB) *StateResolver

func NewStateResolver added in v0.3.20

func NewStateResolver(
	jobLoader JobLoader,
	stateLoader StateLoader,
) *StateResolver

func (*StateResolver) GetJobState added in v0.3.20

func (resolver *StateResolver) GetJobState(ctx context.Context, id string) (model.JobState, error)

func (*StateResolver) GetResults added in v0.3.20

func (resolver *StateResolver) GetResults(ctx context.Context, jobID string) ([]model.PublishedResult, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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