Documentation ¶
Index ¶
- Constants
- Variables
- type BatchStatus
- type DoneBatchStats
- type OpenBatchStats
- type StorageRequest
- type Store
- func (s *Store) AddStorageRequestToOpenBatch(ctx context.Context, opID string, srID broker.StorageRequestID, ...) error
- func (s *Store) Close() error
- func (s *Store) CtxWithTx(ctx context.Context, opts ...storeutil.TxOptions) (context.Context, error)
- func (s *Store) GetNextReadyBatch(ctx context.Context) (batchID broker.BatchID, totalSize int64, srs []StorageRequest, origin string, ...)
- func (s *Store) GetStats(ctx context.Context) ([]OpenBatchStats, []DoneBatchStats, error)
- func (s *Store) MoveBatchToStatus(ctx context.Context, batchID broker.BatchID, delay time.Duration, ...) error
- func (s *Store) TimeBasedBatchClose(ctx context.Context) error
Constants ¶
const ( // StatusOpen is an open batch. StatusOpen = BatchStatus(db.BatchStatusOpen) // StatusReady is a ready to be created batch. StatusReady = BatchStatus(db.BatchStatusReady) // StatusExecuting is a batch being processed. StatusExecuting = BatchStatus(db.BatchStatusExecuting) // StatusDone is an batch that was correctly created. StatusDone = BatchStatus(db.BatchStatusDone) )
Variables ¶
var ( // ErrOperationIDExists indicates that the storage request inclusion // in a batch already exists. ErrOperationIDExists = errors.New("operation-id already exists") )
Functions ¶
This section is empty.
Types ¶
type DoneBatchStats ¶
DoneBatchStats provides information for a done batch.
type OpenBatchStats ¶
OpenBatchStats provides information for an open batch.
type StorageRequest ¶
type StorageRequest = db.StorageRequest
StorageRequest is a storage request from a batch.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a store for unprepared batches.
func New ¶
func New(postgresURI string, batchMaxSize, batchMinSize int64, batchMinWaiting time.Duration, batchWaitScalingFactor int64) (*Store, error)
New returns a new Store.
func (*Store) AddStorageRequestToOpenBatch ¶
func (s *Store) AddStorageRequestToOpenBatch( ctx context.Context, opID string, srID broker.StorageRequestID, dataCid cid.Cid, dataSize int64, origin string) error
AddStorageRequestToOpenBatch adds a storage request to an open batch if available, and creates one if that isn't the case.
func (*Store) CtxWithTx ¶
func (s *Store) CtxWithTx(ctx context.Context, opts ...storeutil.TxOptions) (context.Context, error)
CtxWithTx attach a database transaction to the context. It returns the context unchanged if there's error starting the transaction.
func (*Store) GetNextReadyBatch ¶
func (s *Store) GetNextReadyBatch( ctx context.Context) ( batchID broker.BatchID, totalSize int64, srs []StorageRequest, origin string, exists bool, err error)
GetNextReadyBatch returns the next ready batch to be processed batch and changes the status to Executing. The caller is responsible for updating the status later to Ready on error, or Done on success.
func (*Store) GetStats ¶
func (s *Store) GetStats(ctx context.Context) ([]OpenBatchStats, []DoneBatchStats, error)
GetStats return stats about batches.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
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 |