Version: v1.0.0-alpha3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2018 License: Apache-2.0 Imports: 19 Imported by: 0




This section is empty.


This section is empty.


func WithCertificate

func WithCertificate(value *x509.Certificate) options.Opt

WithCertificate sets the X509 certificate used for the TLS connection

func WithConnectTimeout

func WithConnectTimeout(value time.Duration) options.Opt

WithConnectTimeout sets the GRPC connection timeout

func WithFailFast

func WithFailFast(value bool) options.Opt

WithFailFast sets the GRPC fail-fast parameter

func WithHostOverride

func WithHostOverride(value string) options.Opt

WithHostOverride sets the host name that will be used to resolve the TLS certificate

func WithInsecure

func WithInsecure() options.Opt

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


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) Close

func (c *GRPCConnection) Close()

Close closes the 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) 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 {

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL