Documentation ¶
Index ¶
- func WithCertificate(value *x509.Certificate) options.Opt
- func WithConnectTimeout(value time.Duration) options.Opt
- func WithFailFast(value bool) options.Opt
- func WithHostOverride(value string) options.Opt
- func WithInsecure() options.Opt
- func WithKeepAliveParams(value keepalive.ClientParameters) options.Opt
- type CachingConnector
- type GRPCConnection
- type MockCommManager
- type MockInfraProvider
- type StreamProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCertificate ¶
func WithCertificate(value *x509.Certificate) options.Opt
WithCertificate sets the X509 certificate used for the TLS connection
func WithConnectTimeout ¶
WithConnectTimeout sets the GRPC connection timeout
func WithFailFast ¶
WithFailFast sets the GRPC fail-fast parameter
func WithHostOverride ¶
WithHostOverride sets the host name that will be used to resolve the TLS certificate
func WithInsecure ¶
WithInsecure indicates to fall back to an insecure connection if the connection URL does not specify a protocol
func WithKeepAliveParams ¶
func WithKeepAliveParams(value keepalive.ClientParameters) options.Opt
WithKeepAliveParams sets the GRPC keep-alive parameters
Types ¶
type CachingConnector ¶
type CachingConnector struct {
// contains filtered or unexported fields
}
CachingConnector provides the ability to cache GRPC connections. It provides a GRPC compatible Context Dialer interface via the "DialContext" method. Connections provided by this component are monitored for becoming idle or entering shutdown state. When connections has its usages closed for longer than "idleTime", the connection is closed and removed from the connection cache. Callers must release connections by calling the "ReleaseConn" method. The Close method will flush all remaining open connections. This component should be considered unusable after calling Close.
This component has been designed to be safe for concurrency.
func NewCachingConnector ¶
func NewCachingConnector(sweepTime time.Duration, idleTime time.Duration) *CachingConnector
NewCachingConnector creates a GRPC connection cache. The cache is governed by sweepTime and idleTime.
func (*CachingConnector) Close ¶
func (cc *CachingConnector) Close()
Close cleans up cached connections.
func (*CachingConnector) DialContext ¶
func (cc *CachingConnector) DialContext(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
DialContext is a wrapper for grpc.DialContext where connections are cached.
func (*CachingConnector) ReleaseConn ¶
func (cc *CachingConnector) ReleaseConn(conn *grpc.ClientConn)
ReleaseConn notifies the cache that the connection is no longer in use.
type GRPCConnection ¶
type GRPCConnection struct {
// contains filtered or unexported fields
}
GRPCConnection manages the GRPC connection and client stream
func NewConnection ¶
func NewConnection(ctx fabcontext.Client, chConfig fab.ChannelCfg, streamProvider StreamProvider, url string, opts ...options.Opt) (*GRPCConnection, error)
NewConnection creates a new connection
func (*GRPCConnection) ChannelConfig ¶
func (c *GRPCConnection) ChannelConfig() fab.ChannelCfg
ChannelConfig returns the channel configuration
func (*GRPCConnection) Closed ¶
func (c *GRPCConnection) Closed() bool
Closed returns true if the connection has been closed
func (*GRPCConnection) Context ¶
func (c *GRPCConnection) Context() fabcontext.Client
Context returns the context of the client establishing the connection
func (*GRPCConnection) Stream ¶
func (c *GRPCConnection) Stream() grpc.Stream
Stream returns the GRPC stream
func (*GRPCConnection) TLSCertHash ¶
func (c *GRPCConnection) TLSCertHash() []byte
TLSCertHash returns the hash of the TLS cert
type MockCommManager ¶
type MockCommManager struct { }
MockCommManager is a non-caching comm manager used for unit testing
func (*MockCommManager) DialContext ¶
func (m *MockCommManager) DialContext(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
DialContext creates a connection
func (*MockCommManager) ReleaseConn ¶
func (m *MockCommManager) ReleaseConn(conn *grpc.ClientConn)
ReleaseConn closes the connection
type MockInfraProvider ¶
type MockInfraProvider struct {
fabmocks.MockInfraProvider
}
MockInfraProvider overrides the comm manager to return the MockCommManager
func NewMockInfraProvider ¶
func NewMockInfraProvider() *MockInfraProvider
NewMockInfraProvider return a new MockInfraProvider
func (*MockInfraProvider) CommManager ¶
func (f *MockInfraProvider) CommManager() fab.CommManager
CommManager returns the MockCommManager
type StreamProvider ¶
type StreamProvider func(conn *grpc.ClientConn) (grpc.ClientStream, error)
StreamProvider creates a GRPC stream