forked from TrueCloudLab/frostfs-api-go
Evgenii Stratonikov
1473fa588f
gRPC client load-balancing API is ugly as f: 1. It is configured by pre-registering a balancer and the providing JSON configuration. 2. It doesn't allow different credentials for different endpoints (consider using "insecure" localhost and external endpoint). 3. To support frostfs usecase we also need to implement a resolver, which has its own difficulties. 4. https://github.com/grpc/grpc-go/issues/239#issuecomment-264548415 Using interface in place of grpc.ClientConn allows us to provide custom implentation for it (load-balancing, circuit breaker etc.). Refs TrueCloudLab/frostfs-node#1268 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
24 lines
461 B
Go
24 lines
461 B
Go
package client
|
|
|
|
import (
|
|
"io"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// Conn is an interface for grpc client connection.
|
|
type Conn interface {
|
|
grpc.ClientConnInterface
|
|
io.Closer
|
|
}
|
|
|
|
// Conn returns underlying connection.
|
|
//
|
|
// Returns non-nil result after the first Init() call
|
|
// completed without a connection error.
|
|
//
|
|
// Client should not be used after Close() call
|
|
// on the connection: behavior is undefined.
|
|
func (c *Client) Conn() io.Closer {
|
|
return c.conn
|
|
}
|