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
- type CloseRequest
- type CloseResponse
- type CompactRequest
- type CompactResponse
- type DatabaseClient
- func (*DatabaseClient) Backup(io.Writer, uint64) (uint64, error)
- func (c *DatabaseClient) Close() error
- func (c *DatabaseClient) Compact(start, limit []byte) error
- func (c *DatabaseClient) Delete(key []byte) error
- func (c *DatabaseClient) Get(key []byte) ([]byte, error)
- func (c *DatabaseClient) Has(key []byte) (bool, error)
- func (c *DatabaseClient) HealthCheck(ctx context.Context) (interface{}, error)
- func (*DatabaseClient) Load(io.Reader) error
- func (c *DatabaseClient) NewBatch() database.Batch
- func (c *DatabaseClient) NewIterator() database.Iterator
- func (c *DatabaseClient) NewIteratorWithPrefix(prefix []byte) database.Iterator
- func (c *DatabaseClient) NewIteratorWithStart(start []byte) database.Iterator
- func (c *DatabaseClient) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator
- func (c *DatabaseClient) Put(key, value []byte) error
- func (*DatabaseClient) Sync() error
- type DatabaseServer
- func (s *DatabaseServer) Close(_ context.Context, _ *CloseRequest) (*CloseResponse, error)
- func (s *DatabaseServer) Compact(_ context.Context, req *CompactRequest) (*CompactResponse, error)
- func (s *DatabaseServer) Delete(_ context.Context, req *DeleteRequest) (*DeleteResponse, error)
- func (s *DatabaseServer) Get(_ context.Context, req *GetRequest) (*GetResponse, error)
- func (s *DatabaseServer) Has(_ context.Context, req *HasRequest) (*HasResponse, error)
- func (s *DatabaseServer) HealthCheck(ctx context.Context) (*HealthCheckResponse, error)
- func (s *DatabaseServer) IteratorError(_ context.Context, req *IteratorErrorRequest) (*IteratorErrorResponse, error)
- func (s *DatabaseServer) IteratorNext(_ context.Context, req *IteratorNextRequest) (*IteratorNextResponse, error)
- func (s *DatabaseServer) IteratorRelease(_ context.Context, req *IteratorReleaseRequest) (*IteratorReleaseResponse, error)
- func (s *DatabaseServer) NewIteratorWithStartAndPrefix(_ context.Context, req *NewIteratorWithStartAndPrefixRequest) (*NewIteratorWithStartAndPrefixResponse, error)
- func (s *DatabaseServer) Put(_ context.Context, req *PutRequest) (*PutResponse, error)
- func (s *DatabaseServer) Register(r HandlerRegistry)
- func (s *DatabaseServer) WriteBatch(_ context.Context, req *WriteBatchRequest) (*WriteBatchResponse, error)
- type DeleteRequest
- type DeleteResponse
- type Error
- type GetRequest
- type GetResponse
- type HandlerRegistry
- type HasRequest
- type HasResponse
- type HealthCheckResponse
- type IteratorErrorRequest
- type IteratorErrorResponse
- type IteratorNextRequest
- type IteratorNextResponse
- type IteratorReleaseRequest
- type IteratorReleaseResponse
- type NewIteratorWithStartAndPrefixRequest
- type NewIteratorWithStartAndPrefixResponse
- type PutRequest
- type PutResponse
- type Transport
- type WriteBatchRequest
- type WriteBatchResponse
Constants ¶
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) 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 ¶
func (s *DatabaseServer) Close(_ context.Context, _ *CloseRequest) (*CloseResponse, error)
Close services rpcdb.Close.
func (*DatabaseServer) Compact ¶
func (s *DatabaseServer) Compact(_ context.Context, req *CompactRequest) (*CompactResponse, error)
Compact services rpcdb.Compact.
func (*DatabaseServer) Delete ¶
func (s *DatabaseServer) Delete(_ context.Context, req *DeleteRequest) (*DeleteResponse, error)
Delete services rpcdb.Delete.
func (*DatabaseServer) Get ¶
func (s *DatabaseServer) Get(_ context.Context, req *GetRequest) (*GetResponse, error)
Get services rpcdb.Get.
func (*DatabaseServer) Has ¶
func (s *DatabaseServer) Has(_ context.Context, req *HasRequest) (*HasResponse, error)
Has services rpcdb.Has.
func (*DatabaseServer) HealthCheck ¶
func (s *DatabaseServer) HealthCheck(ctx context.Context) (*HealthCheckResponse, error)
HealthCheck services rpcdb.HealthCheck.
func (*DatabaseServer) IteratorError ¶
func (s *DatabaseServer) IteratorError(_ context.Context, req *IteratorErrorRequest) (*IteratorErrorResponse, error)
IteratorError services rpcdb.IteratorError.
func (*DatabaseServer) IteratorNext ¶
func (s *DatabaseServer) IteratorNext(_ context.Context, req *IteratorNextRequest) (*IteratorNextResponse, error)
IteratorNext services rpcdb.IteratorNext.
func (*DatabaseServer) IteratorRelease ¶
func (s *DatabaseServer) IteratorRelease(_ context.Context, req *IteratorReleaseRequest) (*IteratorReleaseResponse, error)
IteratorRelease services rpcdb.IteratorRelease.
func (*DatabaseServer) NewIteratorWithStartAndPrefix ¶
func (s *DatabaseServer) NewIteratorWithStartAndPrefix(_ context.Context, req *NewIteratorWithStartAndPrefixRequest) (*NewIteratorWithStartAndPrefixResponse, error)
NewIteratorWithStartAndPrefix services rpcdb.NewIteratorWithStartAndPrefix.
func (*DatabaseServer) Put ¶
func (s *DatabaseServer) Put(_ context.Context, req *PutRequest) (*PutResponse, error)
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 ¶
func (s *DatabaseServer) WriteBatch(_ context.Context, req *WriteBatchRequest) (*WriteBatchResponse, error)
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
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.