Documentation
¶
Overview ¶
Package rpcdb is luxd's canonical Layer C home for the rpcdb service: one Service implementation backed by a database.Database, with a transport adapter per supported wire protocol.
Layered topology:
Layer A — wire framing (github.com/luxfi/api/zap) Layer B — service spec (data carriers) (github.com/luxfi/proto/rpcdb) Layer C — service impl + transports (this package)
One Service. Many transport adapters. Adding a new transport is a new file that wraps `*Service`; the storage logic stays here and stays orthogonal to framing concerns.
Files:
- service.go (this) — transport-neutral Service struct + methods
- grpc_server.go (build tag `grpc`) — gRPC adapter
- zap_server.go (default) — ZAP adapter
Index ¶
- Constants
- func CodeToErr(code rpcdb.Error) error
- type Service
- func (s *Service) Close(_ context.Context, _ *rpcdb.CloseRequest) (*rpcdb.CloseResponse, error)
- func (s *Service) CloseIterators()
- func (s *Service) Compact(_ context.Context, req *rpcdb.CompactRequest) (*rpcdb.CompactResponse, error)
- func (s *Service) DB() database.Database
- func (s *Service) Delete(_ context.Context, req *rpcdb.DeleteRequest) (*rpcdb.DeleteResponse, error)
- func (s *Service) Get(_ context.Context, req *rpcdb.GetRequest) (*rpcdb.GetResponse, error)
- func (s *Service) Has(_ context.Context, req *rpcdb.HasRequest) (*rpcdb.HasResponse, error)
- func (s *Service) HealthCheck(ctx context.Context) (*rpcdb.HealthCheckResponse, error)
- func (s *Service) IteratorError(_ context.Context, req *rpcdb.IteratorErrorRequest) (*rpcdb.IteratorErrorResponse, error)
- func (s *Service) IteratorNext(_ context.Context, req *rpcdb.IteratorNextRequest) (*rpcdb.IteratorNextResponse, error)
- func (s *Service) IteratorRelease(_ context.Context, req *rpcdb.IteratorReleaseRequest) (*rpcdb.IteratorReleaseResponse, error)
- func (s *Service) NewIteratorWithStartAndPrefix(_ context.Context, req *rpcdb.NewIteratorWithStartAndPrefixRequest) (*rpcdb.NewIteratorWithStartAndPrefixResponse, error)
- func (s *Service) Put(_ context.Context, req *rpcdb.PutRequest) (*rpcdb.PutResponse, error)
- func (s *Service) WriteBatch(_ context.Context, req *rpcdb.WriteBatchRequest) (*rpcdb.WriteBatchResponse, error)
- type ZAPServer
Constants ¶
const ( MsgDBHas zapwire.MessageType = 1 MsgDBGet zapwire.MessageType = 2 MsgDBPut zapwire.MessageType = 3 MsgDBDelete zapwire.MessageType = 4 MsgDBWriteBatch zapwire.MessageType = 5 MsgDBCompact zapwire.MessageType = 6 MsgDBClose zapwire.MessageType = 7 MsgDBHealthCheck zapwire.MessageType = 8 MsgDBIteratorNew zapwire.MessageType = 9 MsgDBIteratorNext zapwire.MessageType = 10 MsgDBIteratorError zapwire.MessageType = 11 MsgDBIteratorRelease zapwire.MessageType = 12 )
ZAP db channel MsgType IDs. These are the wire-level Layer-A dispatch tags for the rpcdb service over ZAP. They live in their own listener (one per VM plugin); they do NOT collide with the VM lifecycle MsgTypes (1..31) or sender (40..49) or warp (50..59) because each listener has its own dispatch table.
Order is the canonical Lane A assignment — the cevm side hard-codes these numbers in `RemoteZapDB::call`. Do not reorder.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶ added in v1.26.26
type Service struct {
// contains filtered or unexported fields
}
Service is the rpcdb service implementation. It holds one `database.Database` and a server-managed iterator pool, and exposes every rpcdb operation as a (request → response) method on Go data carriers from the proto/rpcdb wire-types package.
Service is transport-agnostic: it knows nothing about gRPC, ZAP, or any other framing. Each transport adapter wraps `*Service` and translates its own wire format into these method calls.
func NewService ¶ added in v1.26.26
NewService wraps `db` so it can be served over any transport.
func (*Service) Close ¶ added in v1.26.26
func (s *Service) Close(_ context.Context, _ *rpcdb.CloseRequest) (*rpcdb.CloseResponse, error)
Close services rpcdb.Close.
func (*Service) CloseIterators ¶ added in v1.26.26
func (s *Service) CloseIterators()
CloseIterators releases every server-side iterator. Adapters call this on shutdown so iterators don't leak past the listener.
func (*Service) Compact ¶ added in v1.26.26
func (s *Service) Compact(_ context.Context, req *rpcdb.CompactRequest) (*rpcdb.CompactResponse, error)
Compact services rpcdb.Compact.
func (*Service) DB ¶ added in v1.26.26
DB returns the underlying database. Adapters that need to surface transport-specific behavior (eg. health-check serialization) can reach in for it; everyone else uses the methods.
func (*Service) Delete ¶ added in v1.26.26
func (s *Service) Delete(_ context.Context, req *rpcdb.DeleteRequest) (*rpcdb.DeleteResponse, error)
Delete services rpcdb.Delete.
func (*Service) Get ¶ added in v1.26.26
func (s *Service) Get(_ context.Context, req *rpcdb.GetRequest) (*rpcdb.GetResponse, error)
Get services rpcdb.Get.
func (*Service) Has ¶ added in v1.26.26
func (s *Service) Has(_ context.Context, req *rpcdb.HasRequest) (*rpcdb.HasResponse, error)
Has services rpcdb.Has.
func (*Service) HealthCheck ¶ added in v1.26.26
HealthCheck services rpcdb.HealthCheck.
func (*Service) IteratorError ¶ added in v1.26.26
func (s *Service) IteratorError(_ context.Context, req *rpcdb.IteratorErrorRequest) (*rpcdb.IteratorErrorResponse, error)
IteratorError services rpcdb.IteratorError.
func (*Service) IteratorNext ¶ added in v1.26.26
func (s *Service) IteratorNext(_ context.Context, req *rpcdb.IteratorNextRequest) (*rpcdb.IteratorNextResponse, error)
IteratorNext services rpcdb.IteratorNext, returning up to iterationBatchBytes worth of (key, value) pairs per call. An empty Data slice signals exhaustion.
Returned bytes are deep-copied so the caller can hold them past the next iterator advance; the underlying database.Iterator is allowed to recycle its internal buffers.
func (*Service) IteratorRelease ¶ added in v1.26.26
func (s *Service) IteratorRelease(_ context.Context, req *rpcdb.IteratorReleaseRequest) (*rpcdb.IteratorReleaseResponse, error)
IteratorRelease services rpcdb.IteratorRelease. Idempotent: calling it twice for the same id returns UNSPECIFIED on the second call.
func (*Service) NewIteratorWithStartAndPrefix ¶ added in v1.26.26
func (s *Service) NewIteratorWithStartAndPrefix(_ context.Context, req *rpcdb.NewIteratorWithStartAndPrefixRequest) (*rpcdb.NewIteratorWithStartAndPrefixResponse, error)
NewIteratorWithStartAndPrefix services rpcdb.NewIteratorWithStartAndPrefix.
func (*Service) Put ¶ added in v1.26.26
func (s *Service) Put(_ context.Context, req *rpcdb.PutRequest) (*rpcdb.PutResponse, error)
Put services rpcdb.Put.
func (*Service) WriteBatch ¶ added in v1.26.26
func (s *Service) WriteBatch(_ context.Context, req *rpcdb.WriteBatchRequest) (*rpcdb.WriteBatchResponse, error)
WriteBatch services rpcdb.WriteBatch.
type ZAPServer ¶ added in v1.26.26
type ZAPServer struct {
// contains filtered or unexported fields
}
ZAPServer is the ZAP transport adapter for the rpcdb Service. It owns the listener and the dispatch loop; the actual storage logic lives in *Service. To swap the wire format (eg. to add framing over a different reliable byte stream) write a new file with a new adapter — never edit Service.
func NewZAPServer ¶ added in v1.26.26
NewZAPServer wraps a database.Database for serving over ZAP.
Equivalent to NewZAPServerFromService(NewService(db)) — kept as a one-liner because cevm-side test fixtures and the production rpcchainvm/zap path both build it this way.
func NewZAPServerFromService ¶ added in v1.26.26
NewZAPServerFromService wraps an existing Service for serving over ZAP. Useful when a single Service needs multiple transport adapters at once (eg. tests that want both ZAP and direct in-process calls).
func (*ZAPServer) Addr ¶ added in v1.26.26
Addr returns the bound address (or nil if not yet listening).
func (*ZAPServer) Close ¶ added in v1.26.26
Close releases all iterators and closes the listener. Caller is expected to also cancel the context passed to Serve so the accept loop exits cleanly. Safe to call multiple times.
We deliberately do NOT call s.server.Close() because the upstream zapwire.Server.Close races with in-flight accept (it nils its conns map mid-Serve, causing "assignment to entry in nil map"). Closing the listener is enough to make Accept return; ctx cancellation does the rest.