fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/pkg/fab/comm Index | Files

package comm

import "github.com/hyperledger/fabric-sdk-go/pkg/fab/comm"

Index

Package Files

connection.go connectionopts.go connector.go mocks.go network.go streamconnection.go

func MSPID Uses

func MSPID(cfg fab.EndpointConfig, org string) (string, bool)

MSPID returns the MSP ID for the requested organization

func NetworkPeerConfig Uses

func NetworkPeerConfig(cfg fab.EndpointConfig, key string) (*fab.NetworkPeer, error)

NetworkPeerConfig fetches the peer configuration based on a key (name or URL).

func OptsFromPeerConfig Uses

func OptsFromPeerConfig(peerCfg *fab.PeerConfig) []options.Opt

OptsFromPeerConfig returns a set of connection options from the given peer config

func SearchPeerConfigFromURL Uses

func SearchPeerConfigFromURL(cfg fab.EndpointConfig, url string) (*fab.PeerConfig, error)

SearchPeerConfigFromURL searches for the peer configuration based on a URL.

func WithCertificate Uses

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

WithCertificate sets the X509 certificate used for the TLS connection

func WithConnectTimeout Uses

func WithConnectTimeout(value time.Duration) options.Opt

WithConnectTimeout sets the GRPC connection timeout

func WithFailFast Uses

func WithFailFast(value bool) options.Opt

WithFailFast sets the GRPC fail-fast parameter

func WithHostOverride Uses

func WithHostOverride(value string) options.Opt

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

func WithInsecure Uses

func WithInsecure() options.Opt

WithInsecure indicates to fall back to an insecure connection if the connection URL does not specify a protocol

func WithKeepAliveParams Uses

func WithKeepAliveParams(value keepalive.ClientParameters) options.Opt

WithKeepAliveParams sets the GRPC keep-alive parameters

func WithParentContext Uses

func WithParentContext(value context.Context) options.Opt

WithParentContext sets the parent context

type CachingConnector Uses

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 Uses

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 Uses

func (cc *CachingConnector) Close()

Close cleans up cached connections.

func (*CachingConnector) DialContext Uses

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 Uses

func (cc *CachingConnector) ReleaseConn(conn *grpc.ClientConn)

ReleaseConn notifies the cache that the connection is no longer in use.

type GRPCConnection Uses

type GRPCConnection struct {
    // contains filtered or unexported fields
}

GRPCConnection manages the GRPC connection and client stream

func NewConnection Uses

func NewConnection(ctx fabcontext.Client, url string, opts ...options.Opt) (*GRPCConnection, error)

NewConnection creates a new connection

func (*GRPCConnection) ClientConn Uses

func (c *GRPCConnection) ClientConn() *grpc.ClientConn

ClientConn returns the underlying GRPC connection

func (*GRPCConnection) Close Uses

func (c *GRPCConnection) Close()

Close closes the connection

func (*GRPCConnection) Closed Uses

func (c *GRPCConnection) Closed() bool

Closed returns true if the connection has been closed

func (*GRPCConnection) Context Uses

func (c *GRPCConnection) Context() fabcontext.Client

Context returns the context of the client establishing the connection

func (*GRPCConnection) TLSCertHash Uses

func (c *GRPCConnection) TLSCertHash() []byte

TLSCertHash returns the hash of the TLS cert

type MockCommManager Uses

type MockCommManager struct {
}

MockCommManager is a non-caching comm manager used for unit testing

func (*MockCommManager) DialContext Uses

func (m *MockCommManager) DialContext(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialContext creates a connection

func (*MockCommManager) ReleaseConn Uses

func (m *MockCommManager) ReleaseConn(conn *grpc.ClientConn)

ReleaseConn closes the connection

type MockInfraProvider Uses

type MockInfraProvider struct {
    fabmocks.MockInfraProvider
}

MockInfraProvider overrides the comm manager to return the MockCommManager

func NewMockInfraProvider Uses

func NewMockInfraProvider() *MockInfraProvider

NewMockInfraProvider return a new MockInfraProvider

func (*MockInfraProvider) CommManager Uses

func (f *MockInfraProvider) CommManager() fab.CommManager

CommManager returns the MockCommManager

type StreamConnection Uses

type StreamConnection struct {
    *GRPCConnection
    // contains filtered or unexported fields
}

StreamConnection manages the GRPC connection and client stream

func NewStreamConnection Uses

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 Uses

func (c *StreamConnection) ChannelConfig() fab.ChannelCfg

ChannelConfig returns the channel configuration

func (*StreamConnection) Close Uses

func (c *StreamConnection) Close()

Close closes the connection

func (*StreamConnection) Stream Uses

func (c *StreamConnection) Stream() grpc.ClientStream

Stream returns the GRPC stream

type StreamProvider Uses

type StreamProvider func(conn *grpc.ClientConn) (grpc.ClientStream, error)

StreamProvider creates a GRPC stream

Package comm imports 22 packages (graph) and is imported by 10 packages. Updated 2019-10-23. Refresh now. Tools for package owners.