Documentation ¶
Index ¶
- Constants
- func NewStorageEpoch(skiSession ski.Session, inCommunity *pdi.CommunityEpoch) (*pdi.StorageEpoch, error)
- func NewTxnDecoder(inMakeThreadsafe bool) pdi.TxnDecoder
- func NewTxnEncoder(inMakeThreadsafe bool, inStorageEpoch pdi.StorageEpoch) pdi.TxnEncoder
- type CommitJob
- type ScanJob
- type SendJob
- type StorageConfig
- type Store
- type TxnHelper
Constants ¶
const DefaultImplName = "badger"
DefaultImplName should be used when a datastore impl is not specified
const (
// ProtocolDesc appears in StorageEpochs originating from this impl
ProtocolDesc = "plan/storage/pdi-local/1"
)
Variables ¶
This section is empty.
Functions ¶
func NewStorageEpoch ¶
func NewStorageEpoch( skiSession ski.Session, inCommunity *pdi.CommunityEpoch, ) (*pdi.StorageEpoch, error)
NewStorageEpoch generates a new StorageEpoch, needed when creating a new community.
func NewTxnDecoder ¶
func NewTxnDecoder( inMakeThreadsafe bool, ) pdi.TxnDecoder
NewTxnDecoder creates a TxnDecoder for use with pdi-datastore
func NewTxnEncoder ¶
func NewTxnEncoder( inMakeThreadsafe bool, inStorageEpoch pdi.StorageEpoch, ) pdi.TxnEncoder
NewTxnEncoder creates a new StorageProviderAgent for use with a pdi-datastore StorageProvider. If inSegmentMaxSz == 0, then a default size is chosen
Types ¶
type CommitJob ¶
type CommitJob struct {
Txn pdi.DecodedTxn
}
CommitJob represents a pending CommitTxn() call to a StorageProvider
type ScanJob ¶
type ScanJob struct { TxnScan *pdi.TxnScan Outlet pdi.StorageProvider_ScanServer OnComplete chan error // contains filtered or unexported fields }
ScanJob represents a pending Query() call to a StorageProvider
type SendJob ¶
type SendJob struct { URIDs [][]byte Outlet pdi.StorageProvider_FetchTxnsServer OnComplete chan error }
SendJob represents a pending SendTxns) calls to a StorageProvider
type StorageConfig ¶
type StorageConfig struct { HomePath string `json:"home_path"` ImplName string `json:"impl_name"` StorageEpoch pdi.StorageEpoch `json:"storage_epoch"` }
StorageConfig contains core info about a db/store
type Store ¶
type Store struct { ctx.Context AgentDesc string Config *StorageConfig AbsPath string DecodedCommits chan CommitJob DefaultFileMode os.FileMode // contains filtered or unexported fields }
Store wraps a PLAN community UUID and a datastore
func NewStore ¶
func NewStore( inConfig *StorageConfig, inBasePath string, ) *Store
NewStore makes a new Datastore
func (*Store) DepositTransfers ¶
DepositTransfers deposits the given amount to
func (*Store) DoCommitJob ¶
DoCommitJob queues the given CommitJob
type TxnHelper ¶
TxnHelper wraps ds.Txn for easier Commit() reattempts
func NewTxnHelper ¶
NewTxnHelper returns a helper struct that wraps datastore.Txn for convenience. This makes life easier for reattempting txns if they go stale, etc.
func (*TxnHelper) FatalErr ¶
FatalErr returns the most recent error passed to Finish() *or* an error reflecting that the max number of retries was reached. If non-nil, this reflects that the txn was NOT committed.
func (*TxnHelper) Finish ¶
Finish is called with inFatalErr == nil to denote that the ds.Txn should be committed. If the commit
succeeds, the next call to NextAttempt() will have no effect and return false. If the commit fails (b/c the txn got stale), NextAttempt() will return true until the max number of attempts has been reached.
If inFatalErr != nil, then the current ds.Txn.Discard() is called and the next call to NextAttempt() will return false.
func (*TxnHelper) NextAttempt ¶
NextAttempt is intended to be used to control a for loop and returns true only if:
- the max number of attempts has not been reached
- Finish() has not been called with a non-nil error
- the txn has not yet been committed successfully yet.