Documentation
¶
Overview ¶
Package badger contains an implementation of the persistance.StorageProvider interface. Badger is a pure-go key-value database, not unlike redis. It is made to be embeddable in go applications, and offers both on-disk and in-memory backends.
This is intended to be the default storage backend for RUN-DSP.
Index ¶
- type StorageProvider
- func (sp *StorageProvider) AcquireLock(ctx context.Context, k lockKey) error
- func (sp *StorageProvider) GetAgreement(ctx context.Context, id uuid.UUID) (*odrl.Agreement, error)
- func (sp *StorageProvider) GetContractR(ctx context.Context, pid uuid.UUID, role constants.DataspaceRole) (*contract.Negotiation, error)
- func (sp *StorageProvider) GetContractRW(ctx context.Context, pid uuid.UUID, role constants.DataspaceRole) (*contract.Negotiation, error)
- func (sp *StorageProvider) GetTransferR(ctx context.Context, pid uuid.UUID, role constants.DataspaceRole) (*transfer.Request, error)
- func (sp *StorageProvider) GetTransferRW(ctx context.Context, pid uuid.UUID, role constants.DataspaceRole) (*transfer.Request, error)
- func (sp *StorageProvider) PutAgreement(ctx context.Context, agreement *odrl.Agreement) error
- func (sp *StorageProvider) PutContract(ctx context.Context, negotiation *contract.Negotiation) error
- func (sp *StorageProvider) PutTransfer(ctx context.Context, transfer *transfer.Request) error
- func (sp *StorageProvider) ReleaseLock(ctx context.Context, k lockKey) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StorageProvider ¶
type StorageProvider struct {
// contains filtered or unexported fields
}
func New ¶
New returns a new badger storage provider, using an inMemory setup if the boolean is set, or it will create/reuse the badger database located in dbPath.
func (*StorageProvider) AcquireLock ¶
func (sp *StorageProvider) AcquireLock(ctx context.Context, k lockKey) error
func (*StorageProvider) GetAgreement ¶
func (sp *StorageProvider) GetAgreement( ctx context.Context, id uuid.UUID, ) (*odrl.Agreement, error)
GetAgreement gets an agreement by ID.
func (*StorageProvider) GetContractR ¶
func (sp *StorageProvider) GetContractR( ctx context.Context, pid uuid.UUID, role constants.DataspaceRole, ) (*contract.Negotiation, error)
GetContractR gets a contract and sets the read-only property. It does not check any locks, as the database transaction already freezes the view.
func (*StorageProvider) GetContractRW ¶
func (sp *StorageProvider) GetContractRW( ctx context.Context, pid uuid.UUID, role constants.DataspaceRole, ) (*contract.Negotiation, error)
GetContractRW gets a contract but does NOT set the read-only property, allowing changes to be saved. It will try to acquire a lock, and if it can't it will panic. The panic will be replaced once RUN-DSP reaches beta, but right now we want contract problems to be extremely visible.
func (*StorageProvider) GetTransferR ¶
func (sp *StorageProvider) GetTransferR( ctx context.Context, pid uuid.UUID, role constants.DataspaceRole, ) (*transfer.Request, error)
GetTransferR gets a transfer and sets the read-only property. It does not check any locks, as the database transaction already freezes the view.
func (*StorageProvider) GetTransferRW ¶
func (sp *StorageProvider) GetTransferRW( ctx context.Context, pid uuid.UUID, role constants.DataspaceRole, ) (*transfer.Request, error)
GetTransferRW gets a transfer but does NOT set the read-only property, allowing changes to be saved. It will try to acquire a lock, and if it can't it will panic. The panic will be replaced once RUN-DSP reaches beta, but right now we want transfer problems to be extremely visible.
func (*StorageProvider) PutAgreement ¶
PutAgreement stores an agreement, but should return an error if the agreement ID already exists.
func (*StorageProvider) PutContract ¶
func (sp *StorageProvider) PutContract(ctx context.Context, negotiation *contract.Negotiation) error
PutContract saves a contract to the database. If the contract is set to read-only, it will panic as this is a bug in the code. It will release the lock after it has saved.
func (*StorageProvider) PutTransfer ¶
PutTransfer saves a transfer to the database. If the transfer is set to read-only, it will panic as this is a bug in the code. It will release the lock after it has saved.
func (*StorageProvider) ReleaseLock ¶
func (sp *StorageProvider) ReleaseLock(ctx context.Context, k lockKey) error