Documentation
¶
Overview ¶
Package bccore implements handles and object lifecycles.
Index ¶
- Constants
- type AnyObject
- type Params
- type Queue
- type System
- func (sys *System) Abort(ctx context.Context, txh blobcache.Handle) error
- func (s *System) AbortAll(ctx context.Context) error
- func (sys *System) BeginTx(ctx context.Context, volh blobcache.Handle, txspec blobcache.TxParams) (*blobcache.Handle, error)
- func (s *System) Cleanup(ctx context.Context, now time.Time, onDown func(blobcache.OID)) error
- func (sys *System) Commit(ctx context.Context, txh blobcache.Handle) error
- func (sys *System) Copy(ctx context.Context, txh blobcache.Handle, srcTxns []blobcache.Handle, ...) error
- func (sys *System) Create(ctx context.Context, oid blobcache.OID, x AnyObject, ...) (blobcache.Handle, error)
- func (sys *System) Delete(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID) error
- func (sys *System) Dequeue(ctx context.Context, qh blobcache.Handle, buf []blobcache.Message, ...) (int, error)
- func (sys *System) Drop(_ context.Context, h blobcache.Handle) error
- func (sys *System) Enqueue(ctx context.Context, qh blobcache.Handle, msgs []blobcache.Message) (*blobcache.InsertResp, error)
- func (sys *System) Exists(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, ...) error
- func (sys *System) Fiat(ctx context.Context, oid blobcache.OID, rights blobcache.ActionSet, ...) (blobcache.Handle, error)
- func (sys *System) Get(ctx context.Context, txh blobcache.Handle, cid blobcache.CID, buf []byte, ...) (int, error)
- func (sys *System) Inspect(ctx context.Context, h blobcache.Handle) (blobcache.Info, error)
- func (sys *System) InspectHandle(_ context.Context, h blobcache.Handle) (*blobcache.HandleInfo, error)
- func (sys *System) InspectQueue(ctx context.Context, qh blobcache.Handle) (blobcache.QueueInfo, error)
- func (sys *System) InspectTx(ctx context.Context, txh blobcache.Handle) (*blobcache.TxInfo, error)
- func (sys *System) InspectVolume(ctx context.Context, h blobcache.Handle) (*blobcache.VolumeInfo, error)
- func (sys *System) IsUp(x blobcache.OID) bool
- func (sys *System) IsVisited(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, ...) error
- func (sys *System) KeepAlive(_ context.Context, hs []blobcache.Handle) error
- func (sys *System) Link(ctx context.Context, txh blobcache.Handle, target blobcache.Handle, ...) (*blobcache.LinkToken, error)
- func (sys *System) Load(ctx context.Context, txh blobcache.Handle, dst *[]byte) error
- func (sys *System) Mint(x blobcache.OID, rights blobcache.ActionSet, createdAt time.Time, ...) blobcache.Handle
- func (sys *System) OpenFrom(ctx context.Context, base blobcache.Handle, ltok blobcache.LinkToken, ...) (*blobcache.Handle, error)
- func (sys *System) Post(ctx context.Context, txh blobcache.Handle, data []byte, ...) (blobcache.CID, error)
- func (sys *System) ResolveQueue(qh blobcache.Handle) (Queue, error)
- func (sys *System) ResolveVol(qh blobcache.Handle) (Volume, error)
- func (sys *System) Save(ctx context.Context, txh blobcache.Handle, root []byte) error
- func (sys *System) Share(x blobcache.Handle, mask blobcache.ActionSet) (blobcache.Handle, error)
- func (sys *System) SubToVolume(ctx context.Context, qh blobcache.Handle, volh blobcache.Handle, ...) error
- func (sys *System) Unlink(ctx context.Context, txh blobcache.Handle, targets []blobcache.LinkID) error
- func (sys *System) Visit(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID) error
- func (sys *System) VisitLinks(ctx context.Context, txh blobcache.Handle, targets []blobcache.LinkID) error
- type Tx
- type Volume
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Params ¶
type Params struct {
// Root is the root Volume, which will be given the 0 ID
Root Volume
// Up is called to bring up a Volume or Queue
Up func(ctx context.Context, oid blobcache.OID) (AnyObject, error)
// OnLink is called before the object is linked to.
// The object must be persisted so that it can be loaded later
OnLink func(ctx context.Context, info blobcache.Info, ao AnyObject) error
// OnSave, if not nil, is called on Save.
// This is where schema checks can be performed.
OnSave func(ctx context.Context, vol Volume, tx Tx, root []byte) error
}
type Queue ¶
type Queue interface {
AnyObject
// Enqueue adds messages to the Queue.
// It returns the number of messages accepted.
Enqueue(ctx context.Context, msgs []blobcache.Message) (int, error)
// Dequeue removes messages from the Queue.
Dequeue(ctx context.Context, buf []blobcache.Message, opts blobcache.DequeueOpts) (int, error)
// Down is called when the queue has no remaining handles
Down(ctx context.Context) error
// Config returns the QueueConfig for this queue.
Config() blobcache.QueueConfig
// Backend returns the QueueSpec for this queue.
Backend() blobcache.QueueBackend[blobcache.OID]
}
type System ¶
type System struct {
// contains filtered or unexported fields
}
System manages objects and handles to those objects
func (*System) Cleanup ¶
Cleanup should be called periodically, so that unused handles can be expired.
func (*System) Dequeue ¶
func (sys *System) Dequeue(ctx context.Context, qh blobcache.Handle, buf []blobcache.Message, opts blobcache.DequeueOpts) (int, error)
Dequeue implements blobcache.QueueAPI.Dequeue
func (*System) Enqueue ¶
func (sys *System) Enqueue(ctx context.Context, qh blobcache.Handle, msgs []blobcache.Message) (*blobcache.InsertResp, error)
Enqueue implements blobcache.QueueAPI.Enqueue
func (*System) Fiat ¶
func (sys *System) Fiat(ctx context.Context, oid blobcache.OID, rights blobcache.ActionSet, createdAt time.Time, ttl time.Duration) (blobcache.Handle, error)
Fiat brings up the object if necessary and creates a new handle
func (*System) InspectHandle ¶
func (sys *System) InspectHandle(_ context.Context, h blobcache.Handle) (*blobcache.HandleInfo, error)
InspectHandle implements blobcache.HandleAPI.InspectHandle
func (*System) InspectQueue ¶
func (sys *System) InspectQueue(ctx context.Context, qh blobcache.Handle) (blobcache.QueueInfo, error)
InspectQueue implements blobcache.QueueAPI.InspectQueue
func (*System) InspectVolume ¶
func (*System) IsUp ¶
IsUp returns true if x has at least one active handle pointing at it, and it's state is loaded in memory.
func (*System) SubToVolume ¶
func (sys *System) SubToVolume(ctx context.Context, qh blobcache.Handle, volh blobcache.Handle, spec blobcache.VolSubSpec) error
SubToVolume subscribes vol to q. This allows aribtrary volumes to be subscribed to arbitrary queues, but this is not the correct thing for a Node to do in the general case, Nodes should forward subscriptions to remote Volumes and Queues when both are on the same Node.
type Tx ¶
type Tx interface {
Params() blobcache.TxParams
Commit(ctx context.Context) error
Abort(ctx context.Context) error
Save(ctx context.Context, src []byte) error
Load(ctx context.Context, dst *[]byte) error
Post(ctx context.Context, data []byte, opts blobcache.PostOpts) (blobcache.CID, error)
Get(ctx context.Context, cid blobcache.CID, buf []byte, opts blobcache.GetOpts) (int, error)
Delete(ctx context.Context, cids []blobcache.CID) error
Exists(ctx context.Context, cids []blobcache.CID, dst *blobcache.BitMap) error
IsVisited(ctx context.Context, cids []blobcache.CID, dst *blobcache.BitMap) error
Visit(ctx context.Context, cids []blobcache.CID) error
MaxSize() int
HashAlgo() blobcache.HashAlgo
// Link creates adds a handle to prove access to a volume.
Link(ctx context.Context, svoid blobcache.OID, rights blobcache.ActionSet, subvol AnyObject) (*blobcache.LinkToken, error)
// Unlink removes a link from the volume.
Unlink(ctx context.Context, targets []blobcache.LinkID) error
// VisitLinks visits a link to another volume.
// This is only usable in a GC transaction.
VisitLinks(ctx context.Context, targets []blobcache.LinkID) error
}
Tx is a consistent view of a volume, during a transaction.
type Volume ¶
type Volume interface {
AnyObject
// GetParams returns the effective parameters of the volume.
GetParams() blobcache.VolumeConfig
// GetBackend returns the backend of the volume.
GetBackend() blobcache.VolumeBackend[blobcache.OID]
BeginTx(ctx context.Context, spec blobcache.TxParams) (Tx, error)
// AccessSubVolume returns the rights granted to access a subvolume.
// Returns 0 if there is no link to the target.
AccessSubVolume(ctx context.Context, target blobcache.LinkToken) (blobcache.ActionSet, error)
}