tendermint/grpcdb/client.go
Emmanuel T Odeke 1260b75f63
grpcdb: Better readability for docs and constructor names
* Added some docs for NewClient, BindServer, *server.Init
* Security level clarified, whether "secure" for https
or "insecure" for non-https gRPC connections.
2018-05-07 22:00:38 +02:00

30 lines
681 B
Go

package grpcdb
import (
"google.golang.org/grpc"
protodb "github.com/tendermint/tmlibs/proto"
)
// Security defines how the client will talk to the gRPC server.
type Security uint
const (
Insecure Security = iota
Secure
)
// NewClient creates a gRPC client connected to the bound gRPC server at serverAddr.
// Use kind to set the level of security to either Secure or Insecure.
func NewClient(serverAddr string, kind Security) (protodb.DBClient, error) {
var opts []grpc.DialOption
if kind == Insecure {
opts = append(opts, grpc.WithInsecure())
}
cc, err := grpc.Dial(serverAddr, opts...)
if err != nil {
return nil, err
}
return protodb.NewDBClient(cc), nil
}