Documentation
¶
Overview ¶
Package bclocal implements a local Blobcache service.
Index ¶
- Constants
- func AddDefaultSchema(name blobcache.SchemaName, constructor schema.Constructor)
- func DefaultPebbleOptions() *pebble.Options
- func DefaultRoot() blobcache.VolumeSpec
- func DefaultSchemas() map[blobcache.SchemaName]schema.Constructor
- type AllOrNothingPolicy
- type Config
- type Env
- type ErrNotAllowed
- type LocalVolumeID
- type Policy
- type RefCount
- type Service
- func (s *Service) Abort(ctx context.Context, txh blobcache.Handle) error
- func (s *Service) AbortAll(ctx context.Context) error
- func (s *Service) AllowLink(ctx context.Context, txh blobcache.Handle, subvolh blobcache.Handle) error
- func (s *Service) Await(ctx context.Context, cond blobcache.Conditions) error
- func (s *Service) BeginTx(ctx context.Context, volh blobcache.Handle, txspec blobcache.TxParams) (*blobcache.Handle, error)
- func (s *Service) Cleanup(ctx context.Context) error
- func (s *Service) CloneVolume(ctx context.Context, caller *blobcache.PeerID, volh blobcache.Handle) (*blobcache.Handle, error)
- func (s *Service) Close() error
- func (s *Service) Commit(ctx context.Context, txh blobcache.Handle) error
- func (s *Service) Copy(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, ...) error
- func (s *Service) CreateVolume(ctx context.Context, host *blobcache.Endpoint, vspec blobcache.VolumeSpec) (*blobcache.Handle, error)
- func (s *Service) Delete(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID) error
- func (s *Service) Drop(ctx context.Context, h blobcache.Handle) error
- func (s *Service) Endpoint(ctx context.Context) (blobcache.Endpoint, error)
- func (s *Service) Exists(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, dst []bool) error
- func (s *Service) Get(ctx context.Context, txh blobcache.Handle, cid blobcache.CID, buf []byte, ...) (int, error)
- func (s *Service) InspectHandle(ctx context.Context, h blobcache.Handle) (*blobcache.HandleInfo, error)
- func (s *Service) InspectTx(ctx context.Context, txh blobcache.Handle) (*blobcache.TxInfo, error)
- func (s *Service) InspectVolume(ctx context.Context, h blobcache.Handle) (*blobcache.VolumeInfo, error)
- func (s *Service) IsVisited(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID, dst []bool) error
- func (s *Service) KeepAlive(ctx context.Context, hs []blobcache.Handle) error
- func (s *Service) Load(ctx context.Context, txh blobcache.Handle, dst *[]byte) error
- func (s *Service) LocalID() blobcache.PeerID
- func (s *Service) OpenFiat(ctx context.Context, x blobcache.OID, mask blobcache.ActionSet) (*blobcache.Handle, error)
- func (s *Service) OpenFrom(ctx context.Context, base blobcache.Handle, x blobcache.OID, ...) (*blobcache.Handle, error)
- func (s *Service) Post(ctx context.Context, txh blobcache.Handle, data []byte, ...) (blobcache.CID, error)
- func (s *Service) Save(ctx context.Context, txh blobcache.Handle, root []byte) error
- func (s *Service) Serve(ctx context.Context, pc net.PacketConn) error
- func (s *Service) Share(ctx context.Context, h blobcache.Handle, to blobcache.PeerID, ...) (*blobcache.Handle, error)
- func (s *Service) Visit(ctx context.Context, txh blobcache.Handle, cids []blobcache.CID) error
Constants ¶
const ( // DefaultVolumeTTL is the default time to live for a volume handle. DefaultVolumeTTL = 5 * time.Minute // DefaultTxTTL is the default time to live for a transaction handle. DefaultTxTTL = 1 * time.Minute // MaxMaxBlobSize is the maximum value that a Volume's max size can be set to. MaxMaxBlobSize = 1 << 24 )
Variables ¶
This section is empty.
Functions ¶
func AddDefaultSchema ¶
func AddDefaultSchema(name blobcache.SchemaName, constructor schema.Constructor)
func DefaultRoot ¶
func DefaultRoot() blobcache.VolumeSpec
DefaultRoot returns the default root volume spec. It uses the basicns schema and a 2MB byte max size.
func DefaultSchemas ¶
func DefaultSchemas() map[blobcache.SchemaName]schema.Constructor
Types ¶
type AllOrNothingPolicy ¶
AllOrNothingPolicy is a policy that allows or disallows all actions for all peers.
func (*AllOrNothingPolicy) CanConnect ¶
func (p *AllOrNothingPolicy) CanConnect(peer blobcache.PeerID) bool
type Config ¶
type Config struct {
// When set to true, the service will not sync the database and blob directory.
NoSync bool
}
Config contains configuration for the service. Config{} works fine. You don't need to worry about anything in here.
type Env ¶
type Env struct {
Background context.Context
// StateDir is the directory where all the state is stored.
StateDir string
// PrivateKey determines the node's identity.
// It must be provided if PacketConn is set.
PrivateKey ed25519.PrivateKey
// Schemas is the supported schemas.
Schemas map[blobcache.SchemaName]schema.Constructor
// Root is the spec to use for the root volume.
Root blobcache.VolumeSpec
// Policy control network access to the service.
Policy Policy
}
func NewTestEnv ¶
NewTestEnv creates a test environment. It uses: - t.TempDir() to create a temporary directory - creates a UDP socket on a random port. All the resources are cleaned up when the test is done.
type ErrNotAllowed ¶
func (ErrNotAllowed) Error ¶
func (e ErrNotAllowed) Error() string
type LocalVolumeID ¶
type LocalVolumeID uint64
func (LocalVolumeID) Marshal ¶
func (lvid LocalVolumeID) Marshal(out []byte) []byte
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements a blobcache.Service.
func NewTestService ¶
NewTestService creates a service scoped to the life of the test. It calls NewTestEnv and NewTestServiceFromEnv
func NewTestServiceFromEnv ¶
NewTestServiceFromEnv creates a service from an environment. It runs the service in the background and forcibly aborts all transactions when the test is done.
func (*Service) Cleanup ¶
Cleanup runs the full cleanup process. This method is called periodically by Run, but it can also be called manually.
func (*Service) CloneVolume ¶
func (*Service) CreateVolume ¶
func (*Service) Endpoint ¶
Endpoint blocks waiting for a node to be created (happens when Serve is running). And then returns the Endpoint for that Node.
func (*Service) InspectHandle ¶
func (*Service) InspectVolume ¶
func (*Service) Serve ¶
Serve handles requests from the network. Serve blocks untilt the context is cancelled, or Close is called. Cancelling the context will cause Run to return without an error. If Serve is *not* running, then remote volumes will not work, hosted on this Node or other Nodes.