tokenmanage

package
v0.0.0-...-476b611 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrBadToken

type ErrBadToken struct{ Err error }

ErrBadToken is an error indicating that there is an issue with the token itself

func (ErrBadToken) Error

func (e ErrBadToken) Error() string

func (ErrBadToken) Unwrap

func (e ErrBadToken) Unwrap() error

type ErrContractFlaking

type ErrContractFlaking struct {
	Chain    persist.Chain
	Contract persist.Address
	Err      error
	Duration time.Duration
}

ErrContractFlaking indicates that runs of this contract are frequently failing

func (ErrContractFlaking) Error

func (e ErrContractFlaking) Error() string

func (ErrContractFlaking) Unwrap

func (e ErrContractFlaking) Unwrap() error

type ErrContractPaused

type ErrContractPaused struct {
	Chain    persist.Chain
	Contract persist.Address
}

ErrContractPaused indicates that runs for this contract have been paused

func (ErrContractPaused) Error

func (e ErrContractPaused) Error() string

type Manager

type Manager struct {
	Registry  *Registry
	Submitter Submitter
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, taskClient *task.Client, cache *redis.Cache, tickTokenF TickTokenF) *Manager

func NewWithRetries

func NewWithRetries(ctx context.Context, taskClient *task.Client, cache *redis.Cache, maxRetries func(db.TokenDefinition) int, tickTokenF TickTokenF) *Manager

func (Manager) Paused

func (m Manager) Paused(ctx context.Context, td db.TokenDefinition) bool

IsPaused returns true if runs of this token are paused.

func (Manager) Processing

func (m Manager) Processing(ctx context.Context, tDefID persist.DBID) bool

Processing returns true if the token is processing or enqueued.

func (Manager) StartProcessing

func (m Manager) StartProcessing(ctx context.Context, td db.TokenDefinition, attempts int, cause persist.ProcessingCause) (func(db.TokenMedia, error) error, error)

StartProcessing marks a token as processing. It returns a callback that must be called when work on the token is finished in order to mark it as finished. If withRetry is true, the callback will attempt to reenqueue the token if an error is passed. attemps is ignored when MaxRetries is set to the default value of 0.

type Registry

type Registry struct{ Cache *redis.Cache }

Registry handles the storing of object state managed by Manager

func (Registry) SetEnqueue

func (r Registry) SetEnqueue(ctx context.Context, tDefID persist.DBID) error

type Submitter

type Submitter interface {
	// Handles how new tokens to Gallery should be processed
	SubmitNewTokens(ctx context.Context, tokenDefinitionIDs []persist.DBID) error
	// Handles how a token that is up for retry should be processed
	SubmitTokenForRetry(ctx context.Context, tokenDefinitionID persist.DBID, attempt int, delayFor time.Duration) error
}

type TickTokenF

type TickTokenF func(db.TokenDefinition) (time.Duration, error)

TickTokenF marks a token as ran and returns the wait time before it can be run again

type TokenProcessingSubmitter

type TokenProcessingSubmitter struct {
	TaskClient *task.Client
	Registry   *Registry
}

func (*TokenProcessingSubmitter) SubmitNewTokens

func (t *TokenProcessingSubmitter) SubmitNewTokens(ctx context.Context, tokenDefinitionIDs []persist.DBID) error

func (*TokenProcessingSubmitter) SubmitTokenForRetry

func (t *TokenProcessingSubmitter) SubmitTokenForRetry(ctx context.Context, tokenDefinitionID persist.DBID, attempt int, delayFor time.Duration) error

Jump to

Keyboard shortcuts

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