Documentation
¶
Index ¶
- Constants
- func CheckBlob(hf HashFunc, salt, cid *CID, data []byte) error
- func IsErrInvalidHandle(err error) bool
- func IsErrNotFound(err error) bool
- func IsErrTooLarge(err error) bool
- func IsErrTxDone(err error) bool
- type AEADAlgo
- type ActionSet
- type CID
- type DEK
- type Endpoint
- type ErrBadData
- type ErrCannotSalt
- type ErrInvalidHandle
- type ErrNoLink
- type ErrNotFound
- type ErrPermission
- type ErrTooLarge
- type ErrTxDone
- type ErrTxNotGC
- type ErrTxReadOnly
- type FQOID
- type GetOpts
- type Handle
- type HandleAPI
- type HandleInfo
- type HashAlgo
- type HashFunc
- type InsertResp
- type Message
- type NextOpts
- type OID
- func (o OID) Compare(other OID) int
- func (o OID) Marshal(out []byte) []byte
- func (o OID) MarshalText() ([]byte, error)
- func (o *OID) Scan(src any) error
- func (o OID) String() string
- func (o *OID) Unmarshal(data []byte) error
- func (o *OID) UnmarshalText(data []byte) error
- func (o OID) Value() (driver.Value, error)
- type OIDPath
- type PeerID
- type PostOpts
- type QueueAPI
- type QueueBackend
- type QueueBackend_Memory
- type QueueBackend_Remote
- type QueueInfo
- type QueueSpec
- type SchemaName
- type SchemaSpec
- type Secret
- type Service
- type TID
- type TxAPI
- type TxInfo
- type TxParams
- type URL
- type VolumeAPI
- type VolumeBackend
- type VolumeBackend_Consensus
- type VolumeBackend_Git
- type VolumeBackend_Local
- type VolumeBackend_Remote
- type VolumeBackend_Vault
- type VolumeConfig
- type VolumeInfo
- 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 // Action_TX_UNLINK_FROM allows a transaction to remove a link from another Volume. // It gates the Unlink operation. // On a Volume handle it constrains the operations that can be performed in transactions created with that handle. Action_TX_UNLINK_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_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 << 26 // Action_VOLUME_SUB_TO allows a Queue to be subscribed // to a Volume's changes. Action_VOLUME_SUB_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_QUEUE_INSPECT allows the queue to be inspected Action_QUEUE_INSPECT = 1 << (iota + 1) // Action_QUEUE_NEXT allows items to be read form the Queue Action_QUEUE_NEXT // Action_QUEUE_INSERT allows items to be inserted into the Queue Action_QUEUE_INSERT // Action_QUEUE_SUB_VOLUME allows the Queue to be subscribe to volumes Action_QUEUE_SUB_VOLUME // Action_QUEUE_CREATE allows creation of queues. // This is never used on a handle // But it is useful to be able to refer to it with the other actions using the ActionSet type. Action_QUEUE_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 EndpointSize = PeerIDSize + 16 + 2
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 IsErrInvalidHandle ¶
func IsErrNotFound ¶
func IsErrTooLarge ¶
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 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 ¶
type ErrNotFound = cadata.ErrNotFound
ErrNotFound is returned when a blob is not found.
type ErrPermission ¶
func (ErrPermission) Error ¶
func (e ErrPermission) Error() string
type ErrTooLarge ¶
ErrTooLarge is returned when a blob is exceeds the maximum size of the Volume.
func (ErrTooLarge) Error ¶
func (e ErrTooLarge) 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. Volumes and transactions are both considered Objects.
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"`
Rights ActionSet `json:"rights"`
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.
type InsertResp ¶
type InsertResp struct {
// Success is the number of messages that were inserted.
Success uint32
}
type Message ¶
type NextOpts ¶
type NextOpts struct {
// Min is the minimum number of messages to read before returning.
// set to 0 for non blocking.
// If there are messages available at the start of the call,
// they must be emitted even if Min is 0
Min uint32 `json:"min"`
// LeaveIn will cause the emitted messages to stay in the queue.
LeaveIn bool `json:"leave_in"`
// Skip drops this many messages before emitting any
Skip uint32 `json:"skip"`
// MaxWait is the maximum amount of time to wait.
MaxWait *time.Duration `json:"max_wait"`
}
type QueueAPI ¶
type QueueAPI interface {
// CreateQueue creates a new queue and returns a handle to it.
CreateQueue(ctx context.Context, host *Endpoint, qspec QueueSpec) (*Handle, error)
// Next reads from the queue.
// It reads into buf until buf is full or another criteria is fulfilled.
Next(ctx context.Context, q Handle, buf []Message, opts NextOpts) (int, error)
// Insert adds the messages to the end of the queue.
Insert(ctx context.Context, from *Endpoint, q Handle, msgs []Message) (*InsertResp, error)
// SubToVolume causes all changes to a Volume's cell to be
// writen as message to the queue.
SubToVolume(ctx context.Context, q Handle, vol Handle) error
}
type QueueBackend ¶
type QueueBackend[T handleOrOID] struct {
Memory *QueueBackend_Memory `json:"memory,omitempty"`
Remote *QueueBackend_Remote `json:"remote,omitempty"`
}
func (QueueBackend[T]) Marshal ¶
func (qb QueueBackend[T]) Marshal(out []byte) []byte
func (*QueueBackend[T]) Unmarshal ¶
func (qb *QueueBackend[T]) Unmarshal(data []byte) error
type QueueBackend_Memory ¶
type QueueBackend_Remote ¶
type QueueInfo ¶
type QueueInfo struct {
ID OID `json:"id"`
Spec QueueBackend[OID] `json:"spec"`
}
QueueInfo is info about a queue.
type QueueSpec ¶
type QueueSpec = QueueBackend[Handle]
type SchemaSpec ¶
type SchemaSpec struct {
// Name is the name of the schema.
Name SchemaName `json:"name"`
// Params are the parameters for the schema.
Params json.RawMessage `json:"params,omitempty"`
}
func (SchemaSpec) Marshal ¶
func (s SchemaSpec) Marshal(out []byte) []byte
func (*SchemaSpec) Unmarshal ¶
func (s *SchemaSpec) Unmarshal(data []byte) error
type Secret ¶
type Secret [32]byte
func (Secret) MarshalJSON ¶
func (*Secret) UnmarshalJSON ¶
func (*Secret) UnmarshalText ¶
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, srcTxns []Handle, cids []CID, success []bool) 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
// Link adds a link to another volume.
// All Link operations take effect atomically on Commit
Link(ctx context.Context, tx Handle, target Handle, mask ActionSet) error
// Unlink removes a link from the transaction's volume to any and all of the OIDs
// All Unlink operations take effect atomically on Commit.
Unlink(ctx context.Context, tx Handle, targets []OID) error
// VisitLink visits a link to another volume.
// This is only usable in a GC transaction.
// Any unvisited links will be deleted at the end of a GC transaction.
VisitLinks(ctx context.Context, tx Handle, targets []OID) error
}
type TxParams ¶
type TxParams struct {
// Modify is true if the transaction will change the Volume's state.
Modify 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 URL ¶
URL is the location of an Object in the Blobcache Network
func (URL) MarshalText ¶
func (*URL) UnmarshalText ¶
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)
// 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"`
Consensus *VolumeBackend_Consensus `json:"consensus,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]) Config ¶
func (v VolumeBackend[T]) Config() VolumeConfig
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]) 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_Consensus ¶
type VolumeBackend_Consensus struct {
Schema SchemaSpec `json:"schema"`
HashAlgo HashAlgo `json:"hash_algo"`
MaxSize int64 `json:"max_size"`
}
type VolumeBackend_Git ¶
type VolumeBackend_Git struct {
URL string `json:"url"`
VolumeConfig
}
type VolumeBackend_Local ¶
type VolumeBackend_Local struct {
Schema SchemaSpec `json:"schema"`
HashAlgo HashAlgo `json:"hash_algo"`
MaxSize int64 `json:"max_size"`
Salted bool `json:"salted"`
}
func VolumeBackend_LocalFromConfig ¶
func VolumeBackend_LocalFromConfig(x VolumeConfig) *VolumeBackend_Local
func (*VolumeBackend_Local) Validate ¶
func (v *VolumeBackend_Local) Validate() error
type VolumeBackend_Remote ¶
type VolumeBackend_Vault ¶
type VolumeBackend_Vault[T handleOrOID] struct {
X T `json:"x"`
Secret Secret `json:"secret"`
HashAlgo HashAlgo `json:"hash_algo"`
}
func (*VolumeBackend_Vault[T]) Validate ¶
func (v *VolumeBackend_Vault[T]) Validate() error
type VolumeConfig ¶
type VolumeConfig struct {
Schema SchemaSpec `json:"schema"`
HashAlgo HashAlgo `json:"hash_algo"`
MaxSize int64 `json:"max_size"`
Salted bool `json:"salted"`
}
VolumeConfig contains parameters common to all Volumes. Not every volume backend allows them to be specified, but all Volumes have these Values set. e.g. the remote volume does not allow a max size to be specified, that's dictated by the remote node. However, the volume still has an effective max size, which is available if the volume has been mounted on the local Node.
func DefaultVolumeParams ¶
func DefaultVolumeParams() VolumeConfig
func (*VolumeConfig) Validate ¶
func (v *VolumeConfig) Validate() error
type VolumeInfo ¶
type VolumeInfo struct {
// ID is always the local OID for the volume.
ID OID `json:"id"`
VolumeConfig
Backend VolumeBackend[OID] `json:"backend"`
}
VolumeInfo is a volume info.
func (*VolumeInfo) GetRemoteFQOID ¶
func (vi *VolumeInfo) GetRemoteFQOID() FQOID
func (VolumeInfo) Marshal ¶
func (vi VolumeInfo) Marshal(out []byte) []byte
func (*VolumeInfo) Unmarshal ¶
func (vi *VolumeInfo) Unmarshal(data []byte) 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. |