rpcdb

package
v1.26.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package rpcdb provides the default ZAP-backed database RPC.

The host (luxd) holds a `database.Database` (currently zapdb under the hood) and exposes it to a VM plugin process over the ZAP transport. The plugin sees a `database.Database` interface that forwards every call across the wire.

This is the default build — it uses ZAP for transport and pure-Go types from proto/zap/rpcdb on the wire (no protobuf). The grpc build tag selects rpcdb_grpc.go instead, which uses gRPC + the protobuf-generated types under proto/pb/rpcdb. The two are mutually exclusive: build with `-tags=grpc` or with no tag, never both.

Index

Constants

View Source
const (
	Error_ERROR_UNSPECIFIED = zaprpcdb.Error_ERROR_UNSPECIFIED
	Error_ERROR_CLOSED      = zaprpcdb.Error_ERROR_CLOSED
	Error_ERROR_NOT_FOUND   = zaprpcdb.Error_ERROR_NOT_FOUND
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseRequest added in v1.26.3

type CloseRequest = zaprpcdb.CloseRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type CloseResponse added in v1.26.3

type CloseResponse = zaprpcdb.CloseResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type CompactRequest added in v1.26.3

type CompactRequest = zaprpcdb.CompactRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type CompactResponse added in v1.26.3

type CompactResponse = zaprpcdb.CompactResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type DatabaseClient

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

DatabaseClient is the plugin-side database that forwards every call to a remote DatabaseServer over a ZAP Transport. Implements database.Database, so the plugin can drop it in unmodified.

func NewClient

func NewClient(t Transport) *DatabaseClient

NewClient builds a DatabaseClient that talks to a DatabaseServer across `t`.

func (*DatabaseClient) Backup added in v1.22.83

func (*DatabaseClient) Backup(io.Writer, uint64) (uint64, error)

Backup is not supported across an RPC boundary.

func (*DatabaseClient) Close

func (c *DatabaseClient) Close() error

Close forwards rpcdb.Close.

func (*DatabaseClient) Compact

func (c *DatabaseClient) Compact(start, limit []byte) error

Compact forwards rpcdb.Compact.

func (*DatabaseClient) Delete

func (c *DatabaseClient) Delete(key []byte) error

Delete forwards rpcdb.Delete.

func (*DatabaseClient) Get

func (c *DatabaseClient) Get(key []byte) ([]byte, error)

Get forwards rpcdb.Get.

func (*DatabaseClient) Has

func (c *DatabaseClient) Has(key []byte) (bool, error)

Has forwards rpcdb.Has.

func (*DatabaseClient) HealthCheck

func (c *DatabaseClient) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck forwards rpcdb.HealthCheck.

func (*DatabaseClient) Load added in v1.22.83

func (*DatabaseClient) Load(io.Reader) error

Load is not supported across an RPC boundary.

func (*DatabaseClient) NewBatch

func (c *DatabaseClient) NewBatch() database.Batch

NewBatch returns an in-memory batch that flushes via WriteBatch.

func (*DatabaseClient) NewIterator

func (c *DatabaseClient) NewIterator() database.Iterator

NewIterator returns a forward-only iterator over the entire DB.

func (*DatabaseClient) NewIteratorWithPrefix

func (c *DatabaseClient) NewIteratorWithPrefix(prefix []byte) database.Iterator

NewIteratorWithPrefix returns a forward-only iterator over keys matching prefix.

func (*DatabaseClient) NewIteratorWithStart

func (c *DatabaseClient) NewIteratorWithStart(start []byte) database.Iterator

NewIteratorWithStart returns a forward-only iterator from start.

func (*DatabaseClient) NewIteratorWithStartAndPrefix

func (c *DatabaseClient) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator

NewIteratorWithStartAndPrefix forwards rpcdb.NewIteratorWithStartAndPrefix.

func (*DatabaseClient) Put

func (c *DatabaseClient) Put(key, value []byte) error

Put forwards rpcdb.Put.

func (*DatabaseClient) Sync added in v1.22.69

func (*DatabaseClient) Sync() error

Sync is a no-op on the client; the server owns persistence.

type DatabaseServer

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

DatabaseServer hosts a `database.Database` over a ZAP transport. The server registers its methods with the transport's handler surface so a remote DatabaseClient can call them. Every database call (Has/Get/Put/…) becomes one round-trip on the underlying connection, which today is a Z-Wing-encrypted ZAP channel.

func NewServer

func NewServer(db database.Database) *DatabaseServer

NewServer wraps `db` for service over a ZAP transport.

func (*DatabaseServer) Close

Close services rpcdb.Close.

func (*DatabaseServer) Compact

Compact services rpcdb.Compact.

func (*DatabaseServer) Delete

Delete services rpcdb.Delete.

func (*DatabaseServer) Get

Get services rpcdb.Get.

func (*DatabaseServer) Has

Has services rpcdb.Has.

func (*DatabaseServer) HealthCheck

func (s *DatabaseServer) HealthCheck(ctx context.Context) (*HealthCheckResponse, error)

HealthCheck services rpcdb.HealthCheck.

func (*DatabaseServer) IteratorError

IteratorError services rpcdb.IteratorError.

func (*DatabaseServer) IteratorNext

IteratorNext services rpcdb.IteratorNext.

func (*DatabaseServer) IteratorRelease

IteratorRelease services rpcdb.IteratorRelease.

func (*DatabaseServer) NewIteratorWithStartAndPrefix

NewIteratorWithStartAndPrefix services rpcdb.NewIteratorWithStartAndPrefix.

func (*DatabaseServer) Put

Put services rpcdb.Put.

func (*DatabaseServer) Register added in v1.26.3

func (s *DatabaseServer) Register(r HandlerRegistry)

Register binds every database method on `r`. The handler signatures reflect the `(ctx, request) -> response` shape of every rpcdb call; the transport is responsible for unmarshaling the request and marshaling the response.

func (*DatabaseServer) WriteBatch

WriteBatch services rpcdb.WriteBatch.

type DeleteRequest added in v1.26.3

type DeleteRequest = zaprpcdb.DeleteRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type DeleteResponse added in v1.26.3

type DeleteResponse = zaprpcdb.DeleteResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type Error added in v1.26.3

type Error = zaprpcdb.Error

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type GetRequest added in v1.26.3

type GetRequest = zaprpcdb.GetRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type GetResponse added in v1.26.3

type GetResponse = zaprpcdb.GetResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type HandlerRegistry added in v1.26.3

type HandlerRegistry interface {
	HandleFunc(method string, handler func(context.Context, any, any) error)
}

Register installs `s` on `r` so a remote DatabaseClient can dial in. `r` is a method-name → handler registry; the ZAP transport in vms/rpcchainvm/zap satisfies this.

type HasRequest added in v1.26.3

type HasRequest = zaprpcdb.HasRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type HasResponse added in v1.26.3

type HasResponse = zaprpcdb.HasResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type HealthCheckResponse added in v1.26.3

type HealthCheckResponse = zaprpcdb.HealthCheckResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type IteratorErrorRequest added in v1.26.3

type IteratorErrorRequest = zaprpcdb.IteratorErrorRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type IteratorErrorResponse added in v1.26.3

type IteratorErrorResponse = zaprpcdb.IteratorErrorResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type IteratorNextRequest added in v1.26.3

type IteratorNextRequest = zaprpcdb.IteratorNextRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type IteratorNextResponse added in v1.26.3

type IteratorNextResponse = zaprpcdb.IteratorNextResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type IteratorReleaseRequest added in v1.26.3

type IteratorReleaseRequest = zaprpcdb.IteratorReleaseRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type IteratorReleaseResponse added in v1.26.3

type IteratorReleaseResponse = zaprpcdb.IteratorReleaseResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type NewIteratorWithStartAndPrefixRequest added in v1.26.3

type NewIteratorWithStartAndPrefixRequest = zaprpcdb.NewIteratorWithStartAndPrefixRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type NewIteratorWithStartAndPrefixResponse added in v1.26.3

type NewIteratorWithStartAndPrefixResponse = zaprpcdb.NewIteratorWithStartAndPrefixResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type PutRequest added in v1.26.3

type PutRequest = zaprpcdb.PutRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type PutResponse added in v1.26.3

type PutResponse = zaprpcdb.PutResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type Transport added in v1.26.3

type Transport interface {
	// Call dispatches a request to the named method and writes the
	// response into out. The on-the-wire encoding of req and out is
	// the transport's responsibility; this package only commits to
	// the named-method shape.
	Call(ctx context.Context, method string, req any, out any) error
}

Transport is the minimal RPC dispatcher abstraction the rpcdb client uses to talk to the server. The default ZAP transport implementation in vms/rpcchainvm/zap satisfies this interface; any other in-process or socket-based transport that can dispatch (method name, request) → response also works.

Keeping this interface in the rpcdb package — rather than importing luxfi/api/zap directly — avoids a circular dependency between the proto layer and the application layer.

type WriteBatchRequest added in v1.26.3

type WriteBatchRequest = zaprpcdb.WriteBatchRequest

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

type WriteBatchResponse added in v1.26.3

type WriteBatchResponse = zaprpcdb.WriteBatchResponse

Re-export the wire types so callers that import "proto/rpcdb" see a single namespace regardless of which transport is active.

Jump to

Keyboard shortcuts

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