blobcache

package
v0.0.0-...-575026b Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Action_ACK is set on any valid handle.
	// Valid handles can always be inspected, dropped, and kept alive.
	Action_ACK = (1 << iota)

	// Action_TX_INSPECT allows the transaction to be inspected.
	// On a Transaction handle it gates the InspectTx operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_INSPECT
	// Action_TX_LOAD allows Load operations in the transaction.
	// On a Transaction handle it gates the Load operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_LOAD
	// Action_TX_SAVE allows Save operations in the transaction.
	// On a Transaction handle it gates the Save operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_SAVE
	// Action_TX_POST allows Post operations in the transaction.
	// On a Transaction handle it gates the Post operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_POST
	// Action_TX_GET allows Get operations in the transaction.
	// On a Transaction handle it gates the Get operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_GET
	// Action_TX_EXISTS allows Exists operations in the transaction.
	// On a Transaction handle it gates the Exists operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_EXISTS
	// Action_TX_DELETE allows Delete operations in the transaction.
	// On a Transaction handle it gates the Delete operation.
	// On a Volume handle:
	// - constrains the operations that can be performed in transactions created with that handle.
	// - gates opening GC transactions on the volume.
	Action_TX_DELETE
	// Action_TX_COPY_FROM allows Copy operations to pull from this transaction.
	// On a Transaction handle is gates using the handle as a source in a Copy operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_COPY_FROM
	// Action_TX_COPY_TO allows a Transaction to be written to in an Copy operation.
	// On a Transaction handle it gates the Copy operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_COPY_TO
	// Action_TX_LINK_FROM allows a transaction to add a link to another Volume.
	// It gates the AllowLink operation.
	// On a Volume handle it constrains the operations that can be performed in transactions created with that handle.
	Action_TX_LINK_FROM
)
View Source
const (
	// Action_VOLUME_INSPECT allows the inspection of volumes.
	// It has no effect on a Transaction handle.
	Action_VOLUME_INSPECT = 1 << 24
	// Action_VOLUME_BEGIN_TX allows the beginning of transactions on a volume
	// It has no effect on a Transaction handle.
	Action_VOLUME_BEGIN_TX = 1 << 25
	// Action_VOLUME_AWAIT allows the awaiting of conditions on a volume
	// It has no effect on a Transaction handle.
	Action_VOLUME_AWAIT = 1 << 26
	// Action_VOLUME_LINK_TO allows a volume to be linked to in an AllowLink operation.
	// If this is not set, then there is no way for the volume to be persisted.
	// It has no effect on a Transaction handle.
	Action_VOLUME_LINK_TO = 1 << 27

	// Action_VOLUME_CLONE allows the Volume to be cloned.
	// It has no effect on a Transaction handle.
	Action_VOLUME_CLONE = 1 << 30
	// Action_VOLUME_CREATE allows the creation of volumes.
	// This is never used on a Volume or Transaction handle.
	// But it is useful to be able to refer to it with the other actions using the ActionSet type.
	Action_VOLUME_CREATE = 1 << 31
)
View Source
const (
	// Action_SHARE_ACK is set if the handle is allowed to be shared.
	Action_SHARE_ACK = Action_ACK << 32
	// Action_SHARE_TX_INSPECT masks TX_INSPECT if the handle is shared.
	Action_SHARE_TX_INSPECT = Action_TX_INSPECT << 32
	// Action_SHARE_TX_LOAD masks TX_LOAD if the handle is shared.
	Action_SHARE_TX_LOAD = Action_TX_LOAD << 32
	// Action_SHARE_TX_POST masks TX_POST if the handle is shared.
	Action_SHARE_TX_POST = Action_TX_POST << 32
	// Action_SHARE_TX_GET masks TX_GET if the handle is shared.
	Action_SHARE_TX_GET = Action_TX_GET << 32
	// Action_SHARE_TX_EXISTS masks TX_EXISTS if the handle is shared.
	Action_SHARE_TX_EXISTS = Action_TX_EXISTS << 32
	// Action_SHARE_TX_DELETE masks TX_DELETE if the handle is shared.
	Action_SHARE_TX_DELETE = Action_TX_DELETE << 32
	// Action_SHARE_TX_ADD_FROM masks TX_ADD_FROM if the handle is shared.
	Action_SHARE_TX_ADD_FROM = Action_TX_COPY_FROM << 32
	// Action_SHARE_TX_LINK_FROM masks TX_LINK_FROM if the handle is shared.
	Action_SHARE_TX_LINK_FROM = Action_TX_LINK_FROM << 32
)
View Source
const Action_ALL = ^ActionSet(0)
View Source
const CIDSize = cadata.IDSize

CIDSize is the number of bytes in a CID.

View Source
const HandleSize = OIDSize + 16

HandleSize is the number of bytes in a handle.

View Source
const OIDSize = 16

OIDSize is the number of bytes in an OID.

View Source
const PeerIDSize = inet256.AddrSize

Variables

This section is empty.

Functions

func CheckBlob

func CheckBlob(hf HashFunc, salt, cid *CID, data []byte) error

CheckBlob checks that the data matches the expected CID. If there is a problem, it returns an ErrBadData.

func ExistsSingle

func ExistsSingle(ctx context.Context, s interface {
	Exists(ctx context.Context, txh Handle, cids []CID, dst []bool) error
}, txh Handle, cid CID) (bool, error)

ExistsSingle is a convenience function for checking if a single CID exists using the slice based API.

func IsErrInvalidHandle

func IsErrInvalidHandle(err error) bool

func IsErrNotFound

func IsErrNotFound(err error) bool

func IsErrTxDone

func IsErrTxDone(err error) bool

Types

type AEADAlgo

type AEADAlgo string

AEADAlgo is an algorithm for Authenticated Encryption with Associated Data (AEAD).

const (
	AEAD_CHACHA20POLY1305 AEADAlgo = "chacha20poly1305"
)

func (AEADAlgo) Validate

func (a AEADAlgo) Validate() error

type ActionSet

type ActionSet uint64

ActionSet is a bitmask of the actions that can be performed using a handle.

func (*ActionSet) Scan

func (r *ActionSet) Scan(x any) error

func (ActionSet) Share

func (a ActionSet) Share() ActionSet

func (ActionSet) String

func (r ActionSet) String() string

type CID

type CID = cadata.ID

CID is a content identifier. It is produced by hashing data. CIDs can be used as salts. CIDs are cannonically printed in an order-preserving base64 encoding, which distinguishes them from OIDs which are printed as hex.

func ParseCID

func ParseCID(s string) (CID, error)

type Conditions

type Conditions struct {
	AllEqual []Handle  `json:"all_equal,omitempty"`
	NOTEqual *NOTEqual `json:"not,omitempty"`
}

Conditions is a set of conditions to await.

func (Conditions) Marshal

func (c Conditions) Marshal(out []byte) []byte

func (*Conditions) Unmarshal

func (c *Conditions) Unmarshal(data []byte) error

type DEK

type DEK [32]byte

DEK is a data encryption key.

func (DEK) MarshalText

func (d DEK) MarshalText() ([]byte, error)

func (DEK) String

func (d DEK) String() string

func (*DEK) UnmarshalText

func (d *DEK) UnmarshalText(data []byte) error

type Endpoint

type Endpoint struct {
	Peer   PeerID         `json:"peer"`
	IPPort netip.AddrPort `json:"ip_port"`
}

Endpoint is somewhere that a blobcache node can be found. The Zero endpoint means the node is not available on the network.

func ParseEndpoint

func ParseEndpoint(s string) (Endpoint, error)

func (Endpoint) IsZero

func (e Endpoint) IsZero() bool

func (Endpoint) String

func (e Endpoint) String() string

type ErrBadData

type ErrBadData struct {
	Salt     *CID
	Expected CID
	Actual   CID
	Len      int
}

ErrBadData is returned when the data does not match the expected CID.

func (ErrBadData) Error

func (e ErrBadData) Error() string

type ErrCannotSalt

type ErrCannotSalt struct{}

ErrCannotSalt is returned when a salt is provided to a volume that does not support salts.

func (ErrCannotSalt) Error

func (e ErrCannotSalt) Error() string

type ErrInvalidHandle

type ErrInvalidHandle struct {
	Handle Handle
}

ErrInvalidHandle is returned when a handle is invalid.

func (ErrInvalidHandle) Error

func (e ErrInvalidHandle) Error() string
type ErrNoLink struct {
	Base   OID
	Target OID
}

ErrNoLink is returned when a volume does not grant access to the requested target. It is never returned for broken handles, or missing blobs.

func (ErrNoLink) Error

func (e ErrNoLink) Error() string

type ErrNotFound

type ErrNotFound struct {
	Type string
	ID   OID
}

ErrNotFound is returned when a resource is not found.

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type ErrTxDone

type ErrTxDone struct {
	ID OID
}

ErrTxDone is returned when a transaction is already done. This would be when calling Commit twice, or Abort after either a Commit or Abort. Calling Abort more than once is not an error, but it is not useful.

func (ErrTxDone) Error

func (e ErrTxDone) Error() string

type ErrTxNotGC

type ErrTxNotGC struct {
	Op string
}

func (ErrTxNotGC) Error

func (e ErrTxNotGC) Error() string

type ErrTxReadOnly

type ErrTxReadOnly struct {
	Tx OID
	Op string
}

ErrTxReadOnly is returned when a transaction is read-only, and the caller calls a mutating method.

func (ErrTxReadOnly) Error

func (e ErrTxReadOnly) Error() string

type FQOID

type FQOID struct {
	Peer PeerID
	OID  OID
}

FQOID is a fully qualified object identifier. It uniquely identifies an object anywhere on the Blobcache network.

func (FQOID) MarshalText

func (f FQOID) MarshalText() ([]byte, error)

func (FQOID) String

func (f FQOID) String() string

func (*FQOID) UnmarshalText

func (f *FQOID) UnmarshalText(x []byte) error

type GetOpts

type GetOpts struct {
	// Salt is required to verify the data, if the volume uses salts.
	Salt *CID
	// SkipVerify causes the retrieved data not to be verified against the CID.
	// This should only be done if you are going to verify the data at a higher level
	// or if you consider the specific volume backend to be inside your security perimeter.
	SkipVerify bool
}

GetOpts contains options for the Get method.

type Handle

type Handle struct {
	OID    OID
	Secret [16]byte
}

func ParseHandle

func ParseHandle(s string) (Handle, error)

ParseHandle parses a handle from a string.

func (Handle) Marshal

func (h Handle) Marshal(out []byte) []byte

func (Handle) MarshalJSON

func (h Handle) MarshalJSON() ([]byte, error)

func (Handle) String

func (h Handle) String() string

func (*Handle) Unmarshal

func (h *Handle) Unmarshal(data []byte) error

Unmarshal unmarshals a handle from it's binary representation.

func (*Handle) UnmarshalJSON

func (h *Handle) UnmarshalJSON(data []byte) error

type HandleAPI

type HandleAPI interface {
	// Drop causes a handle to be released immediately.
	// If all the handles to an object are dropped, the object is deleted.
	Drop(ctx context.Context, h Handle) error
	// KeepAlive extends the TTL for some handles.
	KeepAlive(ctx context.Context, hs []Handle) error
	// InspectHandle returns info about a handle.
	InspectHandle(ctx context.Context, h Handle) (*HandleInfo, error)
	// Share creates a copy of the handle according to the mask, and the
	// sharing rules for the handles actions.
	Share(ctx context.Context, h Handle, to PeerID, mask ActionSet) (*Handle, error)
}

type HandleInfo

type HandleInfo struct {
	OID OID `json:"oid"`

	CreatedAt tai64.TAI64 `json:"created_at"`
	ExpiresAt tai64.TAI64 `json:"expires_at"`
}

HandleInfo is information about a handle, *NOT* the object it points to.

func (HandleInfo) Marshal

func (hi HandleInfo) Marshal(out []byte) []byte

func (*HandleInfo) Unmarshal

func (hi *HandleInfo) Unmarshal(data []byte) error

type HashAlgo

type HashAlgo string

HashAlgo is a cryptographic hash algorithm.

const (
	HashAlgo_BLAKE3_256  HashAlgo = "blake3-256"
	HashAlgo_BLAKE2b_256 HashAlgo = "blake2b-256"
	HashAlgo_SHA2_256    HashAlgo = "sha2-256"
	HashAlgo_SHA3_256    HashAlgo = "sha3-256"
	HashAlgo_CSHAKE256   HashAlgo = "cshake256"
)

func (HashAlgo) HashFunc

func (h HashAlgo) HashFunc() HashFunc

func (HashAlgo) Validate

func (h HashAlgo) Validate() error

type HashFunc

type HashFunc func(salt *CID, data []byte) CID

HashFunc is a cryptographic hash function.

type NOTEqual

type NOTEqual struct {
	Volume Handle
	Value  []byte
}

type OID

type OID [OIDSize]byte

OID is an object identifier.

func ParseOID

func ParseOID(s string) (OID, error)

func RandomOID

func RandomOID() (ret OID)

func (OID) Compare

func (o OID) Compare(other OID) int

func (OID) Marshal

func (o OID) Marshal(out []byte) []byte

func (*OID) Scan

func (o *OID) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (OID) String

func (o OID) String() string

func (*OID) Unmarshal

func (o *OID) Unmarshal(data []byte) error

func (OID) Value

func (o OID) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type PeerID

type PeerID = inet256.ID

PeerID uniquely identifies a peer by hash of the public key.

type PostOpts

type PostOpts struct {
	Salt *CID
}

PostOpts contains options for the Post method.

type Schema

type Schema string
const (
	Schema_NONE Schema = ""
	// Schema_BasicNS is the schema name for the basic namespace.
	Schema_BasicNS        Schema = "blobcache/basicns"
	Schema_BasicContainer Schema = "blobcache/basiccontainer"
)

type Service

type Service interface {
	// Endpoint returns the endpoint of the service.
	// If the endpoint is the zero value, the service is not listening for peers.
	Endpoint(ctx context.Context) (Endpoint, error)

	HandleAPI
	VolumeAPI
	TxAPI
}

type Tx

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

Tx is a convenience type for managing a transaction within a Service.

func BeginTx

func BeginTx(ctx context.Context, s Service, volH Handle, txp TxParams) (*Tx, error)

BeginTx begins a new transaction and returns the Tx type.

func NewTx

func NewTx(s Service, h Handle, hash HashFunc, maxSize int) *Tx

func (*Tx) Abort

func (tx *Tx) Abort(ctx context.Context) error
func (tx *Tx) AllowLink(ctx context.Context, target Handle) error

func (*Tx) Commit

func (tx *Tx) Commit(ctx context.Context) error

func (*Tx) Delete

func (tx *Tx) Delete(ctx context.Context, cid CID) error

func (*Tx) Exists

func (tx *Tx) Exists(ctx context.Context, cid CID) (bool, error)

func (*Tx) Get

func (tx *Tx) Get(ctx context.Context, cid CID, buf []byte) (int, error)

func (*Tx) Hash

func (tx *Tx) Hash(data []byte) CID

func (*Tx) IsVisited

func (tx *Tx) IsVisited(ctx context.Context, cids []CID, yesVisited []bool) error

func (*Tx) KeepAlive

func (tx *Tx) KeepAlive(ctx context.Context) error

func (*Tx) Load

func (tx *Tx) Load(ctx context.Context, dst *[]byte) error

func (*Tx) MaxSize

func (tx *Tx) MaxSize() int

func (*Tx) Post

func (tx *Tx) Post(ctx context.Context, data []byte) (CID, error)

func (*Tx) Save

func (tx *Tx) Save(ctx context.Context, src []byte) error

func (*Tx) Visit

func (tx *Tx) Visit(ctx context.Context, cids []CID) error

type TxAPI

type TxAPI interface {
	// InspectTx returns info about a transaction.
	InspectTx(ctx context.Context, tx Handle) (*TxInfo, error)
	// Commit commits a transaction.
	Commit(ctx context.Context, tx Handle) error
	// Abort aborts a transaction.
	Abort(ctx context.Context, tx Handle) error
	// Load loads the volume root into dst
	Load(ctx context.Context, tx Handle, dst *[]byte) error
	// Save writes to the volume root.
	// Like all operations in a transaction, Save will not be visible until Commit is called.
	Save(ctx context.Context, tx Handle, src []byte) error
	// Post posts data to the volume
	Post(ctx context.Context, tx Handle, data []byte, opts PostOpts) (CID, error)
	// Get returns the data for a CID.
	Get(ctx context.Context, tx Handle, cid CID, buf []byte, opts GetOpts) (int, error)
	// Exists checks if several CID exists in the volume
	// len(dst) must be equal to len(cids), or Exists will return an error.
	Exists(ctx context.Context, tx Handle, cids []CID, dst []bool) error
	// Delete deletes a CID from the volume
	Delete(ctx context.Context, tx Handle, cids []CID) error
	// Copy has the same effect as Post, but it does not require sending the data to Blobcache.
	// It returns a slice of booleans, indicating if the CID could be added.
	// srcTxns are the transactions to copy from.  They will be checked in random order.
	// If none of them have the blob to copy, then false is written to success for that blob.
	// Error is only returned if there is an internal error, otherwise the success slice is used to signal
	// whether a CID was successfully copied.
	Copy(ctx context.Context, tx Handle, cids []CID, srcTxns []Handle, success []bool) error
	// AllowLink allows the Volume to reference another volume.
	// The volume must still have a recognized Container Schema for the volumes to be persisted.
	AllowLink(ctx context.Context, tx Handle, subvol Handle) error
	// Visit is only usable in a GC transaction.
	// It marks each CID as being visited, so it will not be removed by GC.
	Visit(ctx context.Context, tx Handle, cids []CID) error
	// IsVisited is only usable in a GC transaction.
	// It checks if each CID has been visited.
	IsVisited(ctx context.Context, tx Handle, cids []CID, yesVisited []bool) error
}

type TxInfo

type TxInfo struct {
	ID       OID
	Volume   OID
	MaxSize  int64
	HashAlgo HashAlgo
	Params   TxParams
}

func (TxInfo) Marshal

func (ti TxInfo) Marshal(out []byte) []byte

func (*TxInfo) Unmarshal

func (ti *TxInfo) Unmarshal(data []byte) error

type TxParams

type TxParams struct {
	Mutate bool
	// GC causes the transaction to remove all blobs that have not been
	// observed in the transaction.
	// This happens at the end of the transaction.
	// Mutate must be true if GC is set, or BeginTx will return an error.
	GC bool
}

TxParams are parameters for a transaction. The zero value is a read-only transaction.

func (TxParams) Marshal

func (tp TxParams) Marshal(out []byte) []byte

func (*TxParams) Unmarshal

func (tp *TxParams) Unmarshal(data []byte) error

func (TxParams) Validate

func (tp TxParams) Validate() error

type TxSalt

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

TxSalt is a convenience type for managing a salted transaction within a Service.

func BeginTxSalt

func BeginTxSalt(ctx context.Context, s Service, volH Handle, txp TxParams) (*TxSalt, error)

BeginTxSalt is the salted variant of BeginTx.

func NewTxSalt

func NewTxSalt(s Service, h Handle, hash HashFunc, maxSize int) *TxSalt

func (*TxSalt) Abort

func (tx *TxSalt) Abort(ctx context.Context) error

func (*TxSalt) Commit

func (tx *TxSalt) Commit(ctx context.Context) error

func (*TxSalt) Delete

func (tx *TxSalt) Delete(ctx context.Context, cid CID) error

func (*TxSalt) Exists

func (tx *TxSalt) Exists(ctx context.Context, cid CID) (bool, error)

func (*TxSalt) Get

func (tx *TxSalt) Get(ctx context.Context, cid CID, buf []byte, opts GetOpts) (int, error)

func (*TxSalt) Hash

func (tx *TxSalt) Hash(salt *CID, data []byte) CID

func (*TxSalt) KeepAlive

func (tx *TxSalt) KeepAlive(ctx context.Context) error

func (*TxSalt) Load

func (tx *TxSalt) Load(ctx context.Context, dst *[]byte) error

func (*TxSalt) MaxSize

func (tx *TxSalt) MaxSize() int

func (*TxSalt) Post

func (tx *TxSalt) Post(ctx context.Context, data []byte, opts PostOpts) (CID, error)

func (*TxSalt) Save

func (tx *TxSalt) Save(ctx context.Context, src []byte) error

type VolumeAPI

type VolumeAPI interface {
	// CreateVolume creates a new volume.
	// CreateVolume always creates a Volume on the local Node.
	// CreateVolume returns a handle to the Volume.  If no other references to the Volume
	// have been created by the time the handle expires, the Volume will be deleted.
	// Leave caller nil to skip Authorization checks.
	// Host describes where the Volume should be created.
	// If the Host is nil, the Volume will be created on the local Node.
	CreateVolume(ctx context.Context, host *Endpoint, vspec VolumeSpec) (*Handle, error)
	// InspectVolume returns info about a Volume.
	InspectVolume(ctx context.Context, h Handle) (*VolumeInfo, error)
	// OpenFiat returns a handle to an object by it's ID.
	// This is where any Authorization checks are done.
	// It's called "fiat" because it's up to the Node to say yes or no.
	// The result is implementation dependent, unlike OpenFrom, which should behave
	// the same way on any Node.
	OpenFiat(ctx context.Context, x OID, mask ActionSet) (*Handle, error)
	// OpenFrom returns a handle to an object by it's ID.
	// base is the handle of a Volume, which links to the object.
	// the base Volume's schema must be a Container.
	OpenFrom(ctx context.Context, base Handle, x OID, mask ActionSet) (*Handle, error)
	// Await waits for a set of conditions to be met.
	Await(ctx context.Context, cond Conditions) error
	// BeginTx begins a new transaction, on a Volume.
	BeginTx(ctx context.Context, volh Handle, txp TxParams) (*Handle, error)
	// CloneVolume clones a Volume, copying it's configuration, blobs, and cell data.
	CloneVolume(ctx context.Context, caller *PeerID, volh Handle) (*Handle, error)
}

type VolumeBackend

type VolumeBackend[T handleOrOID] struct {
	Local  *VolumeBackend_Local    `json:"local,omitempty"`
	Remote *VolumeBackend_Remote   `json:"remote,omitempty"`
	Git    *VolumeBackend_Git      `json:"git,omitempty"`
	Vault  *VolumeBackend_Vault[T] `json:"vault,omitempty"`
}

VolumeBackend is a specification for a volume backend. If it is going into the API, the it will be a VolumeBackend[Handle]. If it is coming out of the API, the it will be a VolumeBackend[OID].

func VolumeBackendToOID

func VolumeBackendToOID(x VolumeBackend[Handle]) (ret VolumeBackend[OID])

VolumeBackendToOID converts a VolumeBackend[Handle] to a VolumeBackend[OID]. It is used to convert the volume backend to the OID format when it is returned from the API.

func (*VolumeBackend[T]) Deps

func (v *VolumeBackend[T]) Deps() iter.Seq[T]

Deps returns the volumes which must exist before this volume can be created.

func (*VolumeBackend[T]) Marshal

func (v *VolumeBackend[T]) Marshal(out []byte) []byte

func (VolumeBackend[T]) Params

func (v VolumeBackend[T]) Params() VolumeParams

func (VolumeBackend[T]) String

func (v VolumeBackend[T]) String() string

func (*VolumeBackend[T]) Unmarshal

func (v *VolumeBackend[T]) Unmarshal(data []byte) error

func (*VolumeBackend[T]) Validate

func (v *VolumeBackend[T]) Validate() (err error)

type VolumeBackend_Git

type VolumeBackend_Git struct {
	URL string `json:"url"`

	VolumeParams
}

type VolumeBackend_Local

type VolumeBackend_Local struct {
	VolumeParams
}

func (*VolumeBackend_Local) Validate

func (v *VolumeBackend_Local) Validate() error

type VolumeBackend_Remote

type VolumeBackend_Remote struct {
	Endpoint Endpoint `json:"endpoint"`
	Volume   OID      `json:"volume"`
	HashAlgo HashAlgo `json:"hash_algo"`
}

type VolumeBackend_Vault

type VolumeBackend_Vault[T handleOrOID] struct {
	Inner  T        `json:"inner"`
	Secret [32]byte `json:"secret"`
}

type VolumeInfo

type VolumeInfo struct {
	ID OID `json:"id"`
	VolumeParams
	Backend VolumeBackend[OID] `json:"backend"`
}

VolumeInfo is a volume info.

func (VolumeInfo) Marshal

func (vi VolumeInfo) Marshal(out []byte) []byte

func (*VolumeInfo) Unmarshal

func (vi *VolumeInfo) Unmarshal(data []byte) error

type VolumeParams

type VolumeParams struct {
	Schema   Schema   `json:"schema"`
	HashAlgo HashAlgo `json:"hash_algo"`
	MaxSize  int64    `json:"max_size"`
	Salted   bool     `json:"salted"`
}

func DefaultVolumeParams

func DefaultVolumeParams() VolumeParams

func (*VolumeParams) Validate

func (v *VolumeParams) Validate() error

type VolumeSpec

type VolumeSpec = VolumeBackend[Handle]

VolumeSpec is a specification for a volume.

func DefaultLocalSpec

func DefaultLocalSpec() VolumeSpec

DefaultLocalSpec provides sensible defaults for a local volume.

Directories

Path Synopsis
package blobcachetests provides a test suite for blobcache.Service.
package blobcachetests provides a test suite for blobcache.Service.

Jump to

Keyboard shortcuts

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