Documentation
¶
Index ¶
- Constants
- func CheckBlob(hf HashFunc, salt, cid *CID, data []byte) error
- func ExistsSingle(ctx context.Context, s interface{ ... }, txh Handle, cid CID) (bool, error)
- func IsErrInvalidHandle(err error) bool
- func IsErrNotFound(err error) bool
- func IsErrTxDone(err error) bool
- type AEADAlgo
- type ActionSet
- type CID
- type Conditions
- type DEK
- type Endpoint
- type ErrBadData
- type ErrCannotSalt
- type ErrInvalidHandle
- type ErrNoLink
- type ErrNotFound
- type ErrTxDone
- type ErrTxNotGC
- type ErrTxReadOnly
- type FQOID
- type GetOpts
- type Handle
- type HandleAPI
- type HandleInfo
- type HashAlgo
- type HashFunc
- type NOTEqual
- type OID
- type PeerID
- type PostOpts
- type Schema
- type Service
- type Tx
- func (tx *Tx) Abort(ctx context.Context) error
- func (tx *Tx) AllowLink(ctx context.Context, target Handle) error
- func (tx *Tx) Commit(ctx context.Context) error
- func (tx *Tx) Delete(ctx context.Context, cid CID) error
- func (tx *Tx) Exists(ctx context.Context, cid CID) (bool, error)
- func (tx *Tx) Get(ctx context.Context, cid CID, buf []byte) (int, error)
- func (tx *Tx) Hash(data []byte) CID
- func (tx *Tx) IsVisited(ctx context.Context, cids []CID, yesVisited []bool) error
- func (tx *Tx) KeepAlive(ctx context.Context) error
- func (tx *Tx) Load(ctx context.Context, dst *[]byte) error
- func (tx *Tx) MaxSize() int
- func (tx *Tx) Post(ctx context.Context, data []byte) (CID, error)
- func (tx *Tx) Save(ctx context.Context, src []byte) error
- func (tx *Tx) Visit(ctx context.Context, cids []CID) error
- type TxAPI
- type TxInfo
- type TxParams
- type TxSalt
- func (tx *TxSalt) Abort(ctx context.Context) error
- func (tx *TxSalt) Commit(ctx context.Context) error
- func (tx *TxSalt) Delete(ctx context.Context, cid CID) error
- func (tx *TxSalt) Exists(ctx context.Context, cid CID) (bool, error)
- func (tx *TxSalt) Get(ctx context.Context, cid CID, buf []byte, opts GetOpts) (int, error)
- func (tx *TxSalt) Hash(salt *CID, data []byte) CID
- func (tx *TxSalt) KeepAlive(ctx context.Context) error
- func (tx *TxSalt) Load(ctx context.Context, dst *[]byte) error
- func (tx *TxSalt) MaxSize() int
- func (tx *TxSalt) Post(ctx context.Context, data []byte, opts PostOpts) (CID, error)
- func (tx *TxSalt) Save(ctx context.Context, src []byte) error
- type VolumeAPI
- type VolumeBackend
- type VolumeBackend_Git
- type VolumeBackend_Local
- type VolumeBackend_Remote
- type VolumeBackend_Vault
- type VolumeInfo
- type VolumeParams
- type VolumeSpec
Constants ¶
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 )
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 )
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 )
const Action_ALL = ^ActionSet(0)
const CIDSize = cadata.IDSize
CIDSize is the number of bytes in a CID.
const HandleSize = OIDSize + 16
HandleSize is the number of bytes in a handle.
const OIDSize = 16
OIDSize is the number of bytes in an OID.
const PeerIDSize = inet256.AddrSize
Variables ¶
This section is empty.
Functions ¶
func CheckBlob ¶
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 IsErrNotFound ¶
func IsErrTxDone ¶
Types ¶
type AEADAlgo ¶
type AEADAlgo string
AEADAlgo is an algorithm for Authenticated Encryption with Associated Data (AEAD).
const (
AEAD_CHACHA20POLY1305 AEADAlgo = "chacha20poly1305"
)
type ActionSet ¶
type ActionSet uint64
ActionSet is a bitmask of the actions that can be performed using a handle.
type CID ¶
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.
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 (*DEK) UnmarshalText ¶
type Endpoint ¶
Endpoint is somewhere that a blobcache node can be found. The Zero endpoint means the node is not available on the network.
func ParseEndpoint ¶
type ErrBadData ¶
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 ¶
ErrNoLink is returned when a volume does not grant access to the requested target. It is never returned for broken handles, or missing blobs.
type ErrNotFound ¶
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.
type ErrTxNotGC ¶
type ErrTxNotGC struct {
Op string
}
func (ErrTxNotGC) Error ¶
func (e ErrTxNotGC) Error() string
type ErrTxReadOnly ¶
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 ¶
FQOID is a fully qualified object identifier. It uniquely identifies an object anywhere on the Blobcache network.
func (FQOID) MarshalText ¶
func (*FQOID) UnmarshalText ¶
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 ¶
func ParseHandle ¶
ParseHandle parses a handle from a string.
func (Handle) MarshalJSON ¶
func (*Handle) UnmarshalJSON ¶
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) // 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 OID ¶
OID is an object identifier.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a convenience type for managing a transaction within a Service.
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 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.
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 ¶
BeginTxSalt is the salted variant of BeginTx.
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_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.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
package blobcachetests provides a test suite for blobcache.Service.
|
package blobcachetests provides a test suite for blobcache.Service. |