Documentation ¶
Index ¶
- func MSPID(cfg fab.EndpointConfig, org string) (string, bool)
- func NetworkPeerConfig(cfg fab.EndpointConfig, key string) (*fab.NetworkPeer, error)
- func OptsFromPeerConfig(peerCfg *fab.PeerConfig) []options.Opt
- func SearchPeerConfigFromURL(cfg fab.EndpointConfig, url string) (*fab.PeerConfig, error)
- 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 StreamConnection
- type StreamProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MSPID ¶
func MSPID(cfg fab.EndpointConfig, org string) (string, bool)
MSPID returns the MSP ID for the requested organization
func NetworkPeerConfig ¶
func NetworkPeerConfig(cfg fab.EndpointConfig, key string) (*fab.NetworkPeer, error)
NetworkPeerConfig fetches the peer configuration based on a key (name or URL).
func OptsFromPeerConfig ¶
func OptsFromPeerConfig(peerCfg *fab.PeerConfig) []options.Opt
OptsFromPeerConfig returns a set of connection options from the given peer config
func SearchPeerConfigFromURL ¶
func SearchPeerConfigFromURL(cfg fab.EndpointConfig, url string) (*fab.PeerConfig, error)
SearchPeerConfigFromURL searches for the peer configuration based on a URL.
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, url string, opts ...options.Opt) (*GRPCConnection, error)
NewConnection creates a new connection
func (*GRPCConnection) ClientConn ¶
func (c *GRPCConnection) ClientConn() *grpc.ClientConn
ClientConn returns the underlying GRPC connection
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) 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 StreamConnection ¶
type StreamConnection struct { *GRPCConnection // contains filtered or unexported fields }
StreamConnection manages the GRPC connection and client stream
func NewStreamConnection ¶
func NewStreamConnection(ctx fabcontext.Client, chConfig fab.ChannelCfg, streamProvider StreamProvider, url string, opts ...options.Opt) (*StreamConnection, error)
NewStreamConnection creates a new connection with stream
func (*StreamConnection) ChannelConfig ¶
func (c *StreamConnection) ChannelConfig() fab.ChannelCfg
ChannelConfig returns the channel configuration
func (*StreamConnection) Stream ¶
func (c *StreamConnection) Stream() grpc.Stream
Stream returns the GRPC stream
type StreamProvider ¶
type StreamProvider func(conn *grpc.ClientConn) (grpc.ClientStream, error)
StreamProvider creates a GRPC stream