Address PR comments
This commit is contained in:
parent
39e1567d0a
commit
45514a6013
|
@ -17,7 +17,7 @@ const (
|
||||||
|
|
||||||
// NewClient creates a gRPC client connected to the bound gRPC server at serverAddr.
|
// 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.
|
// Use kind to set the level of security to either Secure or Insecure.
|
||||||
func NewClient(serverAddr string, serverCert string) (protodb.DBClient, error) {
|
func NewClient(serverAddr, serverCert string) (protodb.DBClient, error) {
|
||||||
creds, err := credentials.NewClientTLSFromFile(serverCert, "")
|
creds, err := credentials.NewClientTLSFromFile(serverCert, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -21,8 +21,8 @@ should use it, for functionality such as:
|
||||||
|
|
||||||
or
|
or
|
||||||
addr := ":8998"
|
addr := ":8998"
|
||||||
cert := "server.crt"
|
cert := "server.crt"
|
||||||
key := "server.key"
|
key := "server.key"
|
||||||
go func() {
|
go func() {
|
||||||
if err := grpcdb.ListenAndServe(addr, cert, key); err != nil {
|
if err := grpcdb.ListenAndServe(addr, cert, key); err != nil {
|
||||||
log.Fatalf("BindServer: %v", err)
|
log.Fatalf("BindServer: %v", err)
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
// ListenAndServe is a blocking function that sets up a gRPC based
|
// ListenAndServe is a blocking function that sets up a gRPC based
|
||||||
// server at the address supplied, with the gRPC options passed in.
|
// server at the address supplied, with the gRPC options passed in.
|
||||||
// Normally in usage, invoke it in a goroutine like you would for http.ListenAndServe.
|
// Normally in usage, invoke it in a goroutine like you would for http.ListenAndServe.
|
||||||
func ListenAndServe(addr string, cert string, key string, opts ...grpc.ServerOption) error {
|
func ListenAndServe(addr, cert, key string, opts ...grpc.ServerOption) error {
|
||||||
ln, err := net.Listen("tcp", addr)
|
ln, err := net.Listen("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -28,7 +28,7 @@ func ListenAndServe(addr string, cert string, key string, opts ...grpc.ServerOpt
|
||||||
return srv.Serve(ln)
|
return srv.Serve(ln)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(cert string, key string, opts ...grpc.ServerOption) (*grpc.Server, error) {
|
func NewServer(cert, key string, opts ...grpc.ServerOption) (*grpc.Server, error) {
|
||||||
creds, err := credentials.NewServerTLSFromFile(cert, key)
|
creds, err := credentials.NewServerTLSFromFile(cert, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue