state

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0, MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const ErrNoDeleteInProgressTasks = errorString("can only delete tasks that are not-started or tasks that are scheduled")
View Source
const ErrNotAssigned = errorString("tasks must be acquired through pop task")
View Source
const ErrTaskNotFound = errorString("task does not exist")
View Source
const ErrWrongWorker = errorString("task already acquired by other worker")

Variables

This section is empty.

Functions

func WipeAndReset added in v0.0.21

func WipeAndReset(dbConn DBConnector, migrator Migrator) error

Types

type DBConnector

type DBConnector interface {
	Connect() error
	Name() string
	RetryableError(error) bool
	SqlDB() *sql.DB
}

DBConnector provides an interface for working with the underlying DB implementations

func NewDBConnector added in v0.0.21

func NewDBConnector(driver string, conn string) (DBConnector, error)

type Migrator added in v0.0.21

type Migrator func(*sql.DB) error

func NewMigrator added in v0.0.21

func NewMigrator(driver string) (Migrator, error)

type RecordUpdateStatus added in v0.0.5

type RecordUpdateStatus int
const (
	LATEST_UPDATE     RecordUpdateStatus = 1
	PREVIOUS_UPDATE   RecordUpdateStatus = 2
	UNATTACHED_RECORD RecordUpdateStatus = 10
	ATTACHED_RECORD   RecordUpdateStatus = 11
)

type SqlDatastore added in v0.0.50

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

SqlDatastore wraps a datastore.Batching with connection retry implemented in state.DBConnector. We need this because state.DBConnector seems to exist because db connections may drop and timeout during prolonged periods of inactivity, for example. The state.DBConnector is a dealbot construct; therefore, here we wrap a datastore to dynamically reconnect when the DB connection is closed.

func NewSqlDatastore added in v0.0.50

func NewSqlDatastore(connector DBConnector, queries sqlds.Queries) *SqlDatastore

NewSqlDatastore instantiates a new legs datastore backed by DB.

func (*SqlDatastore) Batch added in v0.0.50

func (sds *SqlDatastore) Batch(ctx context.Context) (datastore.Batch, error)

func (*SqlDatastore) Close added in v0.0.50

func (sds *SqlDatastore) Close() error

func (*SqlDatastore) Delete added in v0.0.50

func (sds *SqlDatastore) Delete(ctx context.Context, key datastore.Key) error

func (*SqlDatastore) Get added in v0.0.50

func (sds *SqlDatastore) Get(ctx context.Context, key datastore.Key) (value []byte, err error)

func (*SqlDatastore) GetSize added in v0.0.50

func (sds *SqlDatastore) GetSize(ctx context.Context, key datastore.Key) (size int, err error)

func (*SqlDatastore) Has added in v0.0.50

func (sds *SqlDatastore) Has(ctx context.Context, key datastore.Key) (exists bool, err error)

func (*SqlDatastore) Put added in v0.0.50

func (sds *SqlDatastore) Put(ctx context.Context, key datastore.Key, value []byte) error

func (*SqlDatastore) Query added in v0.0.50

func (sds *SqlDatastore) Query(ctx context.Context, q query.Query) (query.Results, error)

func (*SqlDatastore) Sync added in v0.0.50

func (sds *SqlDatastore) Sync(ctx context.Context, prefix datastore.Key) error

type State

type State interface {
	AssignTask(ctx context.Context, req tasks.PopTask) (tasks.Task, error)
	Get(ctx context.Context, uuid string) (tasks.Task, error)
	GetAll(ctx context.Context) ([]tasks.Task, error)
	GetHead(ctx context.Context, walkback int) (tasks.RecordUpdate, error)
	Update(ctx context.Context, uuid string, req tasks.UpdateTask) (tasks.Task, error)
	NewStorageTask(ctx context.Context, storageTask tasks.StorageTask) (tasks.Task, error)
	NewRetrievalTask(ctx context.Context, retrievalTask tasks.RetrievalTask) (tasks.Task, error)
	DrainWorker(ctx context.Context, worker string) error
	UndrainWorker(ctx context.Context, worker string) error
	PublishRecordsFrom(ctx context.Context, worker string) (cid.Cid, error)
	ResetWorkerTasks(ctx context.Context, worker string) error
	Delete(ctx context.Context, uuid string) error
	Store(ctx context.Context) Store
}

State provides an interface for persistence.

func NewStateDB

func NewStateDB(ctx context.Context, dbConn DBConnector, migrator Migrator, logfile string, identity crypto.PrivKey, recorder metrics.MetricsRecorder) (State, error)

NewStateDB creates a state instance with a given driver and identity

type Store added in v0.0.5

type Store interface {
	Head() (cid.Cid, error)
	Has(context.Context, string) (bool, error)
	Get(context.Context, string) ([]byte, error)
	Put(ctx context.Context, key string, content []byte) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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