store

package
v0.0.0-...-269d6e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBatchExists if the provided batch id already exists.
	ErrBatchExists = errors.New("batch-id already exists")
)

Functions

This section is empty.

Types

type Store

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

Store is a store for unprepared batches.

func New

func New(postgresURI string) (*Store, error)

New returns a new Store.

func (*Store) Close

func (s *Store) Close() error

Close closes the store.

func (*Store) CreateUnpreparedBatch

func (s *Store) CreateUnpreparedBatch(ctx context.Context, sdID broker.BatchID, dataCid cid.Cid) error

CreateUnpreparedBatch creates a new pending unprepared batch to be prepared.

func (*Store) GetNextPending

func (s *Store) GetNextPending(ctx context.Context) (UnpreparedBatch, bool, error)

GetNextPending returns the next pending batch to process and set the status to Executing. The caller is responsible for updating the status later to Pending on error, or Done on success.

func (*Store) MoveToStatus

func (s *Store) MoveToStatus(
	ctx context.Context,
	sdID broker.BatchID,
	delay time.Duration,
	status UnpreparedBatchStatus) error

MoveToStatus moves an executing unprepared job to a new status.

type UnpreparedBatch

type UnpreparedBatch struct {
	BatchID   broker.BatchID
	DataCid   cid.Cid
	ReadyAt   time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

UnpreparedBatch is a batch that is ready to be prepared.

type UnpreparedBatchStatus

type UnpreparedBatchStatus int

UnpreparedBatchStatus is the status of an unprepared batch.

const (
	// StatusPending is an unprepared batch ready to prepared.
	StatusPending UnpreparedBatchStatus = iota
	// StatusExecuting is an unprepared batch being prepared.
	StatusExecuting
	// StatusDone is an unprepared batch already prepared.
	StatusDone
)

Directories

Path Synopsis
internal
db
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql

Jump to

Keyboard shortcuts

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