mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-10 18:16:07 +00:00
Simplified the abstractions to remotedb, a package that
allows clients to use whatever database they can in client
code without having to switch out their code e.g
```go
client, err := remotedb.NewInsecure(":9888")
...
// Just like they'd initialize locally
in := &remotedb.Init{
Name: "test-remote-db",
Type: "leveldb",
Dir: "/tmp/dbs",
}
if err := client.InitRemote(in); err != nil {
log.Fatalf("Failed to initialize the database")
}
v1 := client.Get(k1)
client.Set(k9, dog)
for itr := client.Iterator(a1, z1); itr.Valid(); itr.Next() {
k, v := itr.Key(), itr.Value()
dom := itr.Domain()
...
}
```
31 lines
830 B
Go
31 lines
830 B
Go
/*
|
|
grpcdb is the distribution of Tendermint's db.DB instances using
|
|
the gRPC transport to decouple local db.DB usages from applications,
|
|
to using them over a network in a highly performant manner.
|
|
|
|
grpcdb allows users to initialize a database's server like
|
|
they would locally and invoke the respective methods of db.DB.
|
|
|
|
Most users shouldn't use this package, but should instead use
|
|
remotedb. Only the lower level users and database server deployers
|
|
should use it, for functionality such as:
|
|
|
|
ln, err := net.Listen("tcp", "0.0.0.0:0")
|
|
srv := grpcdb.NewServer()
|
|
defer srv.Stop()
|
|
go func() {
|
|
if err := srv.Serve(ln); err != nil {
|
|
t.Fatalf("BindServer: %v", err)
|
|
}
|
|
}()
|
|
|
|
or
|
|
addr := ":8998"
|
|
go func() {
|
|
if err := grpcdb.ListenAndServe(addr); err != nil {
|
|
log.Fatalf("BindServer: %v", err)
|
|
}
|
|
}()
|
|
*/
|
|
package grpcdb
|