dsadapter

package module
v0.0.0-...-198d7db Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 2 Imported by: 3

README

dsadapter

The dsadapter package/module is a small piece of glue code to connect the github.com/ipfs/go-datastore package, and packages implementing its interfaces, forward into the go-ipld-prime/storage interfaces.

For example, this can be used to use "flatfs" and other datastore plugins with go-ipld-prime storage APIs.

Why structured like this?

See ../README_adapters.md for details about why adapter code is needed, why this is in a module, why it's here, etc.

Which of dsadapter vs bsadapter vs bsrvadapter should I use?

In short: you should prefer direct implementations of the storage APIs over any of these adapters, if one is available with the features you need.

Otherwise, if that's not an option (yet) for some reason, use whichever adapter gets you most directly connected to the code you need.

See ../README_adapters.md for more details and discussion.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Wrapped      datastore.Datastore
	EscapingFunc func(string) string
}

Adapter implements go-ipld-prime/storage.ReadableStorage and go-ipld-prime/storage.WritableStorage backed by a go-datastore.Datastore.

Optionally, an EscapingFunc may also be set, which transforms the (possibly binary) keys considered acceptable by the go-ipld-prime/storage APIs into a subset that the go-datastore can accept. (Be careful to use any escaping consistently, and be wary of potential unexpected behavior if the escaping function might collapse two distinct keys into the same "escaped" key.)

The go-datastore.Datastore may internally have other configuration, such as key sharding functions, etc, and we don't interfere with that here; such configuration should be handled when creating the go-datastore value.

Contexts given to this system are checked for errors at the beginning of an operation, but otherwise have no effect, because the Datastore API doesn't accept context parameters.

func (*Adapter) Get

func (a *Adapter) Get(ctx context.Context, key string) ([]byte, error)

Get implements go-ipld-prime/storage.ReadableStorage.Get.

func (*Adapter) Has

func (a *Adapter) Has(ctx context.Context, key string) (bool, error)

Has implements go-ipld-prime/storage.Storage.Has.

func (*Adapter) Put

func (a *Adapter) Put(ctx context.Context, key string, content []byte) error

Put implements go-ipld-prime/storage.WritableStorage.Put.

Jump to

Keyboard shortcuts

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