Documentation ¶
Index ¶
- func ConstructJobFromEvent(ev model.JobEvent) *model.Job
- func FlattenShardStates(jobState model.JobState) []model.JobShardState
- func GetCompletedVerifiedShardStates(jobState model.JobState) []model.JobShardState
- func GetFilteredShardStates(jobState model.JobState, filterState model.JobStateType) []model.JobShardState
- type JobLoader
- type JobQuery
- type LocalDB
- type LocalDBEventHandler
- type LocalEventFilter
- type StateLoader
- type StateResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlattenShardStates ¶
func FlattenShardStates(jobState model.JobState) []model.JobShardState
func GetCompletedVerifiedShardStates ¶
func GetCompletedVerifiedShardStates(jobState model.JobState) []model.JobShardState
return only shard states that are both complete and verified
func GetFilteredShardStates ¶
func GetFilteredShardStates(jobState model.JobState, filterState model.JobStateType) []model.JobShardState
Types ¶
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 (*LocalDBEventHandler) HandleLocalEvent ¶
func (h *LocalDBEventHandler) HandleLocalEvent(ctx context.Context, event model.JobLocalEvent) error
type LocalEventFilter ¶
type LocalEventFilter func(ev model.JobLocalEvent) bool
type StateResolver ¶
type StateResolver struct {
// contains filtered or unexported fields
}
func GetStateResolver ¶
func GetStateResolver(db LocalDB) *StateResolver
func NewStateResolver ¶
func NewStateResolver( jobLoader JobLoader, stateLoader StateLoader, ) *StateResolver
func (*StateResolver) GetJobState ¶
func (*StateResolver) GetResults ¶
func (resolver *StateResolver) GetResults(ctx context.Context, jobID string) ([]model.PublishedResult, error)
Click to show internal directories.
Click to hide internal directories.