Documentation ¶
Index ¶
- Constants
- type AggregatedSendResult
- type ChannelDeMultiplexer
- type Comm
- type CommConfig
- type ConnConfig
- type MockStream
- type ReceivedMessageImpl
- func (m *ReceivedMessageImpl) Ack(err error)
- func (m *ReceivedMessageImpl) GetConnectionInfo() *protoext.ConnectionInfo
- func (m *ReceivedMessageImpl) GetGossipMessage() *protoext.SignedGossipMessage
- func (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope
- func (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage)
- type RemotePeer
- type SecurityAdvisor
- type SendResult
Constants ¶
const ( DefDialTimeout = time.Second * 3 DefConnTimeout = time.Second * 2 DefRecvBuffSize = 20 DefSendBuffSize = 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregatedSendResult ¶ added in v1.1.1
type AggregatedSendResult []SendResult
AggregatedSendResult represents a slice of SendResults
func (AggregatedSendResult) AckCount ¶ added in v1.1.1
func (ar AggregatedSendResult) AckCount() int
AckCount returns the number of successful acknowledgements
func (AggregatedSendResult) NackCount ¶ added in v1.1.1
func (ar AggregatedSendResult) NackCount() int
NackCount returns the number of unsuccessful acknowledgements
func (AggregatedSendResult) String ¶ added in v1.1.1
func (ar AggregatedSendResult) String() string
String returns a JSONed string representation of the AggregatedSendResult
type ChannelDeMultiplexer ¶
type ChannelDeMultiplexer struct {
// contains filtered or unexported fields
}
ChannelDeMultiplexer is a struct that can receive channel registrations (AddChannel) and publications (DeMultiplex) and it broadcasts the publications to registrations according to their predicate. Can only be closed once and never open after a close.
func NewChannelDemultiplexer ¶
func NewChannelDemultiplexer() *ChannelDeMultiplexer
NewChannelDemultiplexer creates a new ChannelDeMultiplexer
func (*ChannelDeMultiplexer) AddChannel ¶
func (m *ChannelDeMultiplexer) AddChannel(predicate common.MessageAcceptor) <-chan interface{}
AddChannel registers a channel with a certain predicate. AddChannel returns a read-only channel that will produce values that are matched by the predicate function.
If the DeMultiplexer is closed, the channel returned will be closed to prevent users of the channel from waiting on the channel.
func (*ChannelDeMultiplexer) Close ¶
func (m *ChannelDeMultiplexer) Close()
Close closes this channel, which makes all channels registered before to close as well.
func (*ChannelDeMultiplexer) DeMultiplex ¶
func (m *ChannelDeMultiplexer) DeMultiplex(msg interface{})
DeMultiplex broadcasts the message to all channels that were returned by AddChannel calls and that hold the respected predicates.
Blocks if any one channel that would receive msg has a full buffer.
type Comm ¶
type Comm interface { // GetPKIid returns this instance's PKI id GetPKIid() common.PKIidType // Send sends a message to remote peers asynchronously Send(msg *protoext.SignedGossipMessage, peers ...*RemotePeer) // SendWithAck sends a message to remote peers, waiting for acknowledgement from minAck of them, or until a certain timeout expires SendWithAck(msg *protoext.SignedGossipMessage, timeout time.Duration, minAck int, peers ...*RemotePeer) AggregatedSendResult // Probe probes a remote node and returns nil if its responsive, // and an error if it's not. Probe(peer *RemotePeer) error // Handshake authenticates a remote peer and returns // (its identity, nil) on success and (nil, error) Handshake(peer *RemotePeer) (api.PeerIdentityType, error) // Accept returns a dedicated read-only channel for messages sent by other nodes that match a certain predicate. // Each message from the channel can be used to send a reply back to the sender Accept(common.MessageAcceptor) <-chan protoext.ReceivedMessage // PresumedDead returns a read-only channel for node endpoints that are suspected to be offline PresumedDead() <-chan common.PKIidType // IdentitySwitch returns a read-only channel about identity change events IdentitySwitch() <-chan common.PKIidType // CloseConn closes a connection to a certain endpoint CloseConn(peer *RemotePeer) // Stop stops the module Stop() }
Comm is an object that enables to communicate with other peers that also embed a CommModule.
func NewCommInstance ¶
func NewCommInstance(s *grpc.Server, certs *common.TLSCertificates, idStore identity.Mapper, peerIdentity api.PeerIdentityType, secureDialOpts api.PeerSecureDialOpts, sa api.SecurityAdvisor, commMetrics *metrics.CommMetrics, config CommConfig, dialOpts ...grpc.DialOption) (Comm, error)
NewCommInstance creates a new comm instance that binds itself to the given gRPC server
type CommConfig ¶ added in v1.4.1
type CommConfig struct { DialTimeout time.Duration // Dial timeout ConnTimeout time.Duration // Connection timeout RecvBuffSize int // Buffer size of received messages SendBuffSize int // Buffer size of sending messages }
CommConfig is the configuration required to initialize a new comm
type ConnConfig ¶ added in v1.4.1
ConnConfig is the configuration required to initialize a new conn
type MockStream ¶ added in v1.4.11
type MockStream interface { proto.Gossip_GossipStreamClient }
type ReceivedMessageImpl ¶
type ReceivedMessageImpl struct { *protoext.SignedGossipMessage // contains filtered or unexported fields }
ReceivedMessageImpl is an implementation of ReceivedMessage
func (*ReceivedMessageImpl) Ack ¶ added in v1.1.1
func (m *ReceivedMessageImpl) Ack(err error)
Ack returns to the sender an acknowledgement for the message
func (*ReceivedMessageImpl) GetConnectionInfo ¶
func (m *ReceivedMessageImpl) GetConnectionInfo() *protoext.ConnectionInfo
GetConnectionInfo returns information about the remote peer that send the message
func (*ReceivedMessageImpl) GetGossipMessage ¶
func (m *ReceivedMessageImpl) GetGossipMessage() *protoext.SignedGossipMessage
GetGossipMessage returns the inner GossipMessage
func (*ReceivedMessageImpl) GetSourceEnvelope ¶
func (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope
GetSourceEnvelope Returns the Envelope the ReceivedMessage was constructed with
func (*ReceivedMessageImpl) Respond ¶
func (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage)
Respond sends a msg to the source that sent the ReceivedMessageImpl
type RemotePeer ¶
RemotePeer defines a peer's endpoint and its PKIid
func (*RemotePeer) String ¶
func (p *RemotePeer) String() string
String converts a RemotePeer to a string
type SecurityAdvisor ¶ added in v1.3.0
type SecurityAdvisor interface { // OrgByPeerIdentity returns the organization identity of the given PeerIdentityType OrgByPeerIdentity(api.PeerIdentityType) api.OrgIdentityType }
SecurityAdvisor defines an external auxiliary object that provides security and identity related capabilities
type SendResult ¶ added in v1.1.1
type SendResult struct { RemotePeer // contains filtered or unexported fields }
SendResult defines a result of a send to a remote peer
func (SendResult) Error ¶ added in v1.1.1
func (sr SendResult) Error() string
Error returns the error of the SendResult, or an empty string if an error hasn't occurred