jobcompleter

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncCompleter added in v0.1.0

type AsyncCompleter struct {
	baseservice.BaseService
	// contains filtered or unexported fields
}

func NewAsyncCompleter

func NewAsyncCompleter(archetype *baseservice.Archetype, exec PartialExecutor) *AsyncCompleter

func (*AsyncCompleter) JobSetStateIfRunning added in v0.1.0

func (c *AsyncCompleter) JobSetStateIfRunning(ctx context.Context, stats *jobstats.JobStatistics, params *riverdriver.JobSetStateIfRunningParams) error

func (*AsyncCompleter) Start added in v0.1.0

func (c *AsyncCompleter) Start(ctx context.Context) error

func (*AsyncCompleter) Stop added in v0.1.0

func (c *AsyncCompleter) Stop()

func (*AsyncCompleter) Subscribe added in v0.1.0

func (c *AsyncCompleter) Subscribe(subscribeFunc func(update CompleterJobUpdated))

type BatchCompleter added in v0.1.0

type BatchCompleter struct {
	baseservice.BaseService
	startstop.BaseStartStop
	// contains filtered or unexported fields
}

BatchCompleter accumulates incoming completions, and instead of completing them immediately, every so often complete many of them as a single efficient batch. To minimize the amount of driver surface area we need, the batching is only performed for jobs being changed to a `completed` state, which we expect to the vast common case under normal operation. The completer embeds an AsyncCompleter to perform other non-`completed` state completions.

func NewBatchCompleter added in v0.1.0

func NewBatchCompleter(archetype *baseservice.Archetype, exec PartialExecutor) *BatchCompleter

func (*BatchCompleter) JobSetStateIfRunning added in v0.1.0

func (c *BatchCompleter) JobSetStateIfRunning(ctx context.Context, stats *jobstats.JobStatistics, params *riverdriver.JobSetStateIfRunningParams) error

func (*BatchCompleter) Start added in v0.1.0

func (c *BatchCompleter) Start(ctx context.Context) error

func (*BatchCompleter) Stop added in v0.1.0

func (c *BatchCompleter) Stop()

func (*BatchCompleter) Subscribe added in v0.1.0

func (c *BatchCompleter) Subscribe(subscribeFunc func(update CompleterJobUpdated))

func (*BatchCompleter) WaitStarted added in v0.1.0

func (c *BatchCompleter) WaitStarted() <-chan struct{}

type CompleterJobUpdated

type CompleterJobUpdated struct {
	Job      *rivertype.JobRow
	JobStats *jobstats.JobStatistics
}

type InlineCompleter added in v0.1.0

type InlineCompleter struct {
	baseservice.BaseService
	// contains filtered or unexported fields
}

func NewInlineCompleter

func NewInlineCompleter(archetype *baseservice.Archetype, exec PartialExecutor) *InlineCompleter

func (*InlineCompleter) JobSetStateIfRunning added in v0.1.0

func (c *InlineCompleter) JobSetStateIfRunning(ctx context.Context, stats *jobstats.JobStatistics, params *riverdriver.JobSetStateIfRunningParams) error

func (*InlineCompleter) Start added in v0.1.0

func (c *InlineCompleter) Start(ctx context.Context) error

func (*InlineCompleter) Stop added in v0.1.0

func (c *InlineCompleter) Stop()

func (*InlineCompleter) Subscribe added in v0.1.0

func (c *InlineCompleter) Subscribe(subscribeFunc func(update CompleterJobUpdated))

type JobCompleter

type JobCompleter interface {
	startstop.Service

	// JobSetState sets a new state for the given job, as long as it's
	// still running (i.e. its state has not changed to something else already).
	JobSetStateIfRunning(ctx context.Context, stats *jobstats.JobStatistics, params *riverdriver.JobSetStateIfRunningParams) error

	// Subscribe injects a callback which will be invoked whenever a job is
	// updated.
	Subscribe(subscribeFunc func(update CompleterJobUpdated))
}

JobCompleter is an interface to a service that "completes" jobs by marking them with an appropriate state and any other necessary metadata in the database. It's a generic interface to let us experiment with the speed of a number of implementations, although River will likely always prefer our most optimized one.

type PartialExecutor added in v0.0.23

type PartialExecutor interface {
	JobSetCompleteIfRunningMany(ctx context.Context, params *riverdriver.JobSetCompleteIfRunningManyParams) ([]*rivertype.JobRow, error)
	JobSetStateIfRunning(ctx context.Context, params *riverdriver.JobSetStateIfRunningParams) (*rivertype.JobRow, error)
}

PartialExecutor is always a riverdriver.Executor under normal circumstances, but is a minimal interface with the functions needed for completers to work to more easily facilitate mocking.

Jump to

Keyboard shortcuts

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