cluster

package
v1.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRPCTimeout is the default RPC timeout
	// that RPCs use
	DefaultRPCTimeout = time.Second * 5
)

Variables

This section is empty.

Functions

func DERtoPEM

func DERtoPEM(der []byte) string

DERtoPEM returns a PEM representation of the DER encoded certificate

Types

type ChannelExtractor

type ChannelExtractor interface {
	TargetChannel(message proto.Message) string
}

ChannelExtractor extracts the channel of a given message, or returns an empty string if that's not possible

type Client

type Client interface {
	// Submit submits transactions to a cluster member
	Submit(ctx context.Context, opts ...grpc.CallOption) (orderer.Cluster_SubmitClient, error)
	// Step passes an implementation-specific message to another cluster member.
	Step(ctx context.Context, in *orderer.StepRequest, opts ...grpc.CallOption) (*orderer.StepResponse, error)
}

Client is the definition of operations that the Cluster gRPC service exposes to cluster nodes.

type Comm

type Comm struct {
	Lock         sync.RWMutex
	Logger       *logging.Logger
	ChanExt      ChannelExtractor
	H            Handler
	Connections  *ConnectionStore
	Chan2Members MembersByChannel
	RPCTimeout   time.Duration
	// contains filtered or unexported fields
}

Comm implements Communicator

func (*Comm) Configure

func (c *Comm) Configure(channel string, newNodes []RemoteNode)

Configure configures the channel with the given RemoteNodes

func (*Comm) DispatchStep

func (c *Comm) DispatchStep(ctx context.Context, request *orderer.StepRequest) (*orderer.StepResponse, error)

DispatchStep identifies the channel and sender of the step request and passes it to the underlying Handler

func (*Comm) DispatchSubmit

func (c *Comm) DispatchSubmit(ctx context.Context, request *orderer.SubmitRequest) (*orderer.SubmitResponse, error)

DispatchSubmit identifies the channel and sender of the submit request and passes it to the underlying Handler

func (*Comm) Remote

func (c *Comm) Remote(channel string, id uint64) (*RemoteContext, error)

Remote obtains a RemoteContext linked to the destination node on the context of a given channel

func (*Comm) Shutdown

func (c *Comm) Shutdown()

Shutdown shuts down the instance

type Communicator

type Communicator interface {
	// Remote returns a RemoteContext for the given RemoteNode ID in the context
	// of the given channel, or error if connection cannot be established, or
	// the channel wasn't configured
	Remote(channel string, id uint64) (*RemoteContext, error)
	// Configure configures the communication to connect to all
	// given members, and disconnect from any members not among the given
	// members.
	Configure(channel string, members []*RemoteNode)
	// Shutdown shuts down the communicator
	Shutdown()
}

Communicator defines communication for a consenter

type ConnByCertMap

type ConnByCertMap map[string]*grpc.ClientConn

ConnByCertMap maps certificates represented as strings to gRPC connections

func (ConnByCertMap) Lookup

func (cbc ConnByCertMap) Lookup(cert []byte) (*grpc.ClientConn, bool)

Lookup looks up a certificate and returns the connection that was mapped to the certificate, and whether it was found or not

func (ConnByCertMap) Put

func (cbc ConnByCertMap) Put(cert []byte, conn *grpc.ClientConn)

Put associates the given connection to the certificate

func (ConnByCertMap) Remove

func (cbc ConnByCertMap) Remove(cert []byte)

Remove removes the connection that is associated to the given certificate

type ConnectionMapper

type ConnectionMapper interface {
	Lookup(cert []byte) (*grpc.ClientConn, bool)
	Put(cert []byte, conn *grpc.ClientConn)
	Remove(cert []byte)
}

ConnectionMapper maps certificates to connections

type ConnectionStore

type ConnectionStore struct {
	Connections ConnectionMapper
	// contains filtered or unexported fields
}

ConnectionStore stores connections to remote nodes

func NewConnectionStore

func NewConnectionStore(dialer SecureDialer) *ConnectionStore

NewConnectionStore creates a new ConnectionStore with the given SecureDialer

func (*ConnectionStore) Connection

func (c *ConnectionStore) Connection(endpoint string, expectedServerCert []byte) (*grpc.ClientConn, error)

Connection obtains a connection to the given endpoint and expects the given server certificate to be presented by the remote node

func (*ConnectionStore) Disconnect

func (c *ConnectionStore) Disconnect(expectedServerCert []byte)

Disconnect closes the gRPC connection that is mapped to the given certificate

type Dispatcher

type Dispatcher interface {
	DispatchSubmit(ctx context.Context, request *orderer.SubmitRequest) (*orderer.SubmitResponse, error)
	DispatchStep(ctx context.Context, request *orderer.StepRequest) (*orderer.StepResponse, error)
}

Dispatcher dispatches requests

type Handler

type Handler interface {
	OnStep(channel string, sender uint64, req *orderer.StepRequest) (*orderer.StepResponse, error)
	OnSubmit(channel string, sender uint64, req *orderer.SubmitRequest) (*orderer.SubmitResponse, error)
}

Handler handles Step() and Submit() requests and returns a corresponding response

type MemberMapping

type MemberMapping map[uint64]*Stub

MemberMapping defines NetworkMembers by their ID

func (MemberMapping) ByID

func (mp MemberMapping) ByID(ID uint64) *Stub

ByID retrieves the Stub with the given ID from the MemberMapping

func (MemberMapping) LookupByClientCert

func (mp MemberMapping) LookupByClientCert(cert []byte) *Stub

LookupByClientCert retrieves a Stub with the given client certificate

func (MemberMapping) Put

func (mp MemberMapping) Put(stub *Stub)

Put inserts the given stub to the MemberMapping

func (MemberMapping) ServerCertificates

func (mp MemberMapping) ServerCertificates() StringSet

ServerCertificates returns a set of the server certificates represented as strings

type MembersByChannel

type MembersByChannel map[string]MemberMapping

MembersByChannel is a mapping from channel name to MemberMapping

type PredicateDialer

type PredicateDialer struct {
	Config atomic.Value
}

PredicateDialer creates gRPC connections that are only established if the given predicate is fulfilled

func NewTLSPinningDialer

func NewTLSPinningDialer(config comm.ClientConfig) *PredicateDialer

NewTLSPinningDialer creates a new PredicateDialer

func (*PredicateDialer) Dial

func (dialer *PredicateDialer) Dial(address string, verifyFunc RemoteVerifier) (*grpc.ClientConn, error)

Dial creates a new gRPC connection that can only be established, if the remote node's certificate chain satisfy verifyFunc

func (*PredicateDialer) SetConfig

func (dialer *PredicateDialer) SetConfig(config comm.ClientConfig)

SetConfig sets the configuration of the PredicateDialer

type RPC

type RPC struct {
	Channel string
	Comm    RemoteCommunicator
	// contains filtered or unexported fields
}

RPC performs remote procedure calls to remote cluster nodes.

func (*RPC) ReceiveSubmitResponse

func (s *RPC) ReceiveSubmitResponse(destination uint64) (*orderer.SubmitResponse, error)

ReceiveSubmitResponse receives a SubmitResponse from the given destination node

func (*RPC) SendSubmit

func (s *RPC) SendSubmit(destination uint64, request *orderer.SubmitRequest) error

SendSubmit sends a SubmitRequest to the given destination node

func (*RPC) Step

func (s *RPC) Step(destination uint64, msg *orderer.StepRequest) (*orderer.StepResponse, error)

Step sends a StepRequest to the given destination node and returns the response

type RemoteCommunicator

type RemoteCommunicator interface {
	// Remote returns a RemoteContext for the given node ID in the context
	// of the given channel, or error if connection cannot be established, or
	// the channel wasn't configured
	Remote(channel string, id uint64) (*RemoteContext, error)
}

RemoteCommunicator communicates to remote nodes

type RemoteContext

type RemoteContext struct {
	RPCTimeout time.Duration

	Client orderer.ClusterClient
	// contains filtered or unexported fields
}

RemoteContext interacts with remote cluster nodes. Every call can be aborted via call to Abort()

func (*RemoteContext) Abort

func (rc *RemoteContext) Abort()

Abort aborts the contexts the RemoteContext uses, thus effectively causes all operations on the embedded ClusterClient to end.

func (*RemoteContext) Step

Step passes an implementation-specific message to another cluster member.

func (*RemoteContext) SubmitStream

func (rc *RemoteContext) SubmitStream() (orderer.Cluster_SubmitClient, error)

SubmitStream creates a new Submit stream

type RemoteNode

type RemoteNode struct {
	// ID is unique among all members, and cannot be 0.
	ID uint64
	// Endpoint is the endpoint of the node, denoted in %s:%d format
	Endpoint string
	// ServerTLSCert is the DER encoded TLS server certificate of the node
	ServerTLSCert []byte
	// ClientTLSCert is the DER encoded TLS client certificate of the node
	ClientTLSCert []byte
}

RemoteNode represents a cluster member

func (RemoteNode) String

func (rm RemoteNode) String() string

String returns a string representation of this RemoteNode

type RemoteVerifier

type RemoteVerifier func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

RemoteVerifier verifies the connection to the remote host

type SecureDialer

type SecureDialer interface {
	Dial(address string, verifyFunc RemoteVerifier) (*grpc.ClientConn, error)
}

SecureDialer connects to a remote address

type Service

type Service struct {
	Dispatcher Dispatcher
	Logger     logging.Logger
}

Service defines the raft Service

func (*Service) Step

func (s *Service) Step(ctx context.Context, request *orderer.StepRequest) (*orderer.StepResponse, error)

Step forwards a message to a raft FSM located in this server

func (*Service) Submit

func (s *Service) Submit(stream orderer.Cluster_SubmitServer) error

Submit accepts transactions

type StringSet

type StringSet map[string]struct{}

StringSet is a set of strings

type Stub

type Stub struct {
	RemoteNode
	*RemoteContext
	// contains filtered or unexported fields
}

Stub holds all information about the remote node, including the RemoteContext for it, and serializes some operations on it.

func (*Stub) Activate

func (stub *Stub) Activate(createRemoteContext func() (*RemoteContext, error)) error

Activate creates a remote context with the given function callback in an atomic manner - if two parallel invocations are invoked on this Stub, only a single invocation of createRemoteStub takes place.

func (*Stub) Active

func (stub *Stub) Active() bool

Active returns whether the Stub is active or not

func (*Stub) Deactivate

func (stub *Stub) Deactivate()

Deactivate deactivates the Stub and ceases all communication operations invoked on it.

type SubmitClient

type SubmitClient interface {
	Send(request *orderer.SubmitRequest) error
	Recv() (*orderer.SubmitResponse, error)
	grpc.ClientStream
}

SubmitClient is the Submit gRPC stream

type SubmitStream

type SubmitStream interface {
	Send(response *orderer.SubmitResponse) error
	Recv() (*orderer.SubmitRequest, error)
	grpc.ServerStream
}

SubmitStream defines the gRPC stream for sending transactions, and receiving corresponding responses

Directories

Path Synopsis
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

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