Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Basic ¶
Basic represents a basic job. Borrowing the terminology from inheritance, we can think of Basic jobs as the Abstract Base Class for all jobs. Basic jobs define execution, but do not define any behaviour around how/when the job is to be executed, and thus cannot be executed on their own.
type BlockHeaderSub ¶
type BlockHeaderSub interface { Basic Subscribe(ctx context.Context) (ethereum.Subscription, chan *coretypes.Header, error) Unsubscribe(ctx context.Context) }
BlockHeaderSub represents a block watcher job.
type Conditional ¶
Conditional represents a conditional job.
type Custom ¶
type Custom interface { Basic HasProducer }
Custom Jobs are jobs that defines their own producer function. This is useful for adding custom job types without having to make a change to the core `offchain-sdk`.
type EthSubscribable ¶
type EthSubscribable interface { Basic Subscribe(ctx context.Context) (ethereum.Subscription, chan coretypes.Log, error) Unsubscribe(ctx context.Context) }
EthSubscribable represents a subscription to an ethereum event.
type HasMetrics ¶
type HasMetrics interface { Basic }
HasMetrics represents a struct that defines metrics for its internal functions.
type HasProducer ¶
type HasProducer interface { Basic Producer(ctx context.Context, pool WorkerPool) error }
HasProducer represents a struct that defines a producer.
func WrapConditional ¶
func WrapConditional(c Conditional) HasProducer
Wrap Conditional, wraps a conditional job to conform to the producer interface.
func WrapJob ¶
func WrapJob(j Basic) HasProducer
WrapJob wraps a basic job into a job that can be submitted to the worker pool.
func WrapPolling ¶
func WrapPolling(c Polling) HasProducer
WrapPolling wraps a polling job into a conditional job, this is possible since, polling jobs are simply conditional jobs where `Condition()` always returns true. Cute little double wrap that allows us to re-use the producer from `conditional`.
type HasTeardown ¶
HasTeardown represents a job that has a teardown function.
type Polling ¶
Polling represents a polling job. Polling jobs are jobs that are run periodically at a given interval.
type Registry ¶
type Registry struct { // mapRegistry is the underlying map registry of job types to types.Registry[string, Basic] }
Registry is a registry of jobtypes to jobs.
func (*Registry) RegisterJob ¶
RegisterJob registers a job type to the registry.
type Subscribable ¶
Subscribable represents a subscribable job.
type WorkerPool ¶
type WorkerPool interface { Submit(func()) SubmitAndWait(func()) }