Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyDialed = errors.New("connection already dialed")
Functions ¶
func ForwardServerToClient ¶
func ForwardServerToClient(ctx context.Context, params ForwardS2C) error
ForwardServerToClient forwards an incoming ServerStream to an outgoing ClientStream. It either returns an error when the forwarding process fails, or nil when the outgoing stream returns an io.EOF on Recv.
Types ¶
type AdaptedClientConn ¶
type AdaptedClientConn struct {
// contains filtered or unexported fields
}
func AdaptClient ¶
func AdaptClient(conn *grpc.ClientConn) *AdaptedClientConn
AdaptClient wraps an existing gRPC client with an adapter implementing ClientConn. The returned client is instantly ready to be used, and will be valid until *AdaptedClientConn.Close is called, after which any stream initiations via the client will return an error and the underlying gRPC client will be closed, too.
func (*AdaptedClientConn) Close ¶
func (cc *AdaptedClientConn) Close()
Close marks this connection as closed and closes the underlying gRPC client. Calling Close concurrently won't cause issues, but why would you want to even do it...
func (*AdaptedClientConn) Stream ¶
func (cc *AdaptedClientConn) Stream(ctx context.Context, method string) (ClientStream, error)
type AdaptedClientPool ¶
type AdaptedClientPool struct {
// contains filtered or unexported fields
}
func NewAdaptedClientPool ¶
func NewAdaptedClientPool(opts AdaptedClientPoolOpts) *AdaptedClientPool
func (*AdaptedClientPool) Get ¶
func (p *AdaptedClientPool) Get(target string) (ClientConn, bool)
func (*AdaptedClientPool) New ¶
func (p *AdaptedClientPool) New(targetName, dialTarget string, opts ...grpc.DialOption) (*AdaptedClientPoolController, error)
New creates a new *AdaptedClientConn using grpc.NewClient or the NewClientFunc specified in AdaptedClientPoolOpts using the merged set of default options and the options passed to New. It returns a *AdaptedClientPoolController which can be used to close the connection and remove it from the pool.
It is an error to call New() with the same targetName multiple times on a single DialedPool instance, the previous *AdaptedClientPoolController must be explicitly used to close the connection before dialing a new one. Instead of trying to synchronize such procedures, however, it's better to have a properly defined lifecycle for each possible target, with clear logic about when it gets added or removed to/from all the components of a bridge.
type AdaptedClientPoolController ¶
type AdaptedClientPoolController struct {
// contains filtered or unexported fields
}
AdaptedClientPoolController wraps an AdaptedClientConn created using a DialedPool, providing methods to control the AdaptedClientConn's own and pool lifecycle.
func (*AdaptedClientPoolController) Close ¶
func (pw *AdaptedClientPoolController) Close()
Close removes this connection from the pool and closes it. Calling close multiple times or concurrently will intentionally result in a panic to avoid bugs. TODO(renbou): implement graceful connection closure.
type AdaptedClientPoolOpts ¶
type AdaptedClientPoolOpts struct { // NewClientFunc can be used to specify an alternative connection constructor to be used instead of [grpc.NewClient]. NewClientFunc func(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) // DefaultOpts specify the default options to be used when creating a new client, by default no opts are used. DefaultOpts []grpc.DialOption }
type AdaptedClientStream ¶
type AdaptedClientStream struct {
// contains filtered or unexported fields
}
func (*AdaptedClientStream) Close ¶
func (s *AdaptedClientStream) Close()
func (*AdaptedClientStream) CloseSend ¶
func (s *AdaptedClientStream) CloseSend()
type ClientConn ¶
type ClientConn interface { Stream(ctx context.Context, method string) (ClientStream, error) Close() }
type ClientPool ¶
type ClientPool interface {
Get(target string) (ClientConn, bool)
}
type ClientStream ¶
type ForwardS2C ¶
type ForwardS2C struct { Incoming ServerStream Outgoing ClientStream Method *bridgedesc.Method }