remote

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(db keyvalue.Beginner, conn io.ReadWriteCloser, prefix *record.Key, writable bool) error

Serve opens a batch and serves it over the connection. Serve returns once the connection is closed or the remote side calls Commit. See Connect.

func ServeStore

func ServeStore(store keyvalue.Store, conn io.ReadWriteCloser) error

ServeStore serves a key-value store over a connection. ServeStore returns once the connection is closed. See ConnectStore.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a remote key-value database client that creates a connection to the remote database when DB.Begin is called. See Serve.

func Connect

func Connect(connect func() (io.ReadWriteCloser, error)) *DB

Connect returns a DB that uses the given function to connect to a remote key-value database. See Serve.

func (*DB) Begin

func (c *DB) Begin(prefix *database.Key, writable bool) keyvalue.ChangeSet

Begin opens a connection to the remote key-value database and returns a change set that uses RPC to interact with the remote database.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a remote key-value store client that uses RPC to interact with the remote store. See ServeStore.

func ConnectStore

func ConnectStore(conn io.ReadWriter) *Store

ConnectStore returns a Store that uses that uses RPC to interact with a remote store. See ServeStore.

func (*Store) Delete

func (c *Store) Delete(key *record.Key) error

Delete implements keyvalue.Store.Delete.

func (*Store) ForEach

func (c *Store) ForEach(fn func(*record.Key, []byte) error) error

ForEach implements keyvalue.Store.ForEach.

func (*Store) ForEachHash

func (c *Store) ForEachHash(fn func(*record.Key, [32]byte) error) error

ForEachHash calls the callback for each key-value pair in the store. The callback is called with the value's hash instead of the value. See Store.ForEach for comparison.

func (*Store) Get

func (c *Store) Get(key *record.Key) ([]byte, error)

Get implements keyvalue.Store.Get.

func (*Store) GetBatch

func (c *Store) GetBatch(keys []*record.Key) ([][]byte, error)

GetBatch is a batched version of Store.Get. The request and response are transmitted as a single round-trip, which avoids the overhead of individual Get calls.

func (*Store) Put

func (c *Store) Put(key *record.Key, value []byte) error

Put implements keyvalue.Store.Put.

Jump to

Keyboard shortcuts

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