persistence

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package persistence contains the storage interfaces for the dataspace code. It also contains constants and other shared code for the implementation packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgreementSaver

type AgreementSaver interface {
	// GetAgreement gets an agreement by ID.
	GetAgreement(ctx context.Context, id uuid.UUID) (*odrl.Agreement, error)
	// PutAgreement stores an agreement, but should return an error if the agreement ID already
	// exists.
	PutAgreement(ctx context.Context, agreement *odrl.Agreement) error
}

AgreementSaver is an interface for storing/retrieving dataspace agreements. This does not have any locking involved as agreements are immutable.

type ContractSaver

type ContractSaver interface {
	// GetContractR gets a read-only version of a contract.
	GetContractR(
		ctx context.Context,
		pid uuid.UUID,
		role constants.DataspaceRole,
	) (*contract.Negotiation, error)
	// GetContractRW gets a read/write version of a contract. This should set a contract specific
	// lock for the requested contract.
	GetContractRW(
		ctx context.Context,
		pid uuid.UUID,
		role constants.DataspaceRole,
	) (*contract.Negotiation, error)
	// PutContract saves a contract, and releases the contract specific lock. If the contract
	// is read-only, it will return an error.
	PutContract(ctx context.Context, contract *contract.Negotiation) error
}

ContractSaver is an interface for storing/retrieving dataspace contracts. It supports both read-only and read/write versions. Do note that in this implementation that read-only is enforced at save time, as all contract fields are public (for encoding purposes). It is up to the implementer to handle locking of contracts for the read/write instances, and to error if a read-only contract is being saved.

type StorageProvider

type StorageProvider interface {
	ContractSaver
	AgreementSaver
	TransferSaver
	TokenSaver
}

StorageProvider is an interface that combines the *Saver interfaces.

type TokenSaver added in v0.0.5

type TokenSaver interface {
	// GetToken retrieves a token by key.
	GetToken(ctx context.Context, key string) (string, error)
	// DelToken deletes a token by key.
	DelToken(ctx context.Context, key string) error
	// PutToken stores a key/token combination.
	PutToken(ctx context.Context, key, token string) error
}

TokenSaver saves a token to a key, no locking necessary as a token is immutable.

type TransferSaver

type TransferSaver interface {
	// GetTransferR gets a read-only version of a transfer request.
	GetTransferR(
		ctx context.Context,
		pid uuid.UUID,
		role constants.DataspaceRole,
	) (*transfer.Request, error)
	// GetTransferRW gets a read/write version of a transfer request.
	GetTransferRW(
		ctx context.Context,
		pid uuid.UUID,
		role constants.DataspaceRole,
	) (*transfer.Request, error)
	// PutTransfer saves a transfer.
	PutTransfer(ctx context.Context, transfer *transfer.Request) error
}

TransferSaver is an interface for storing dataspace transfer request. The read/write semantics are the same as those for contracts.

Directories

Path Synopsis
Package badger contains an implementation of the persistance.StorageProvider interface.
Package badger contains an implementation of the persistance.StorageProvider interface.

Jump to

Keyboard shortcuts

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