Documentation
¶
Overview ¶
Package transport is a generated GoMock package.
Package transport is a generated GoMock package.
Index ¶
- Constants
- type ConnectionManager
- type Contact
- type Diagnostics
- type MockConnectionManager
- func (m *MockConnectionManager) Connect(peerAddress string, peerDID did.DID, delay *time.Duration)
- func (m *MockConnectionManager) Contacts() []Contact
- func (m *MockConnectionManager) Diagnostics() []core.DiagnosticResult
- func (m *MockConnectionManager) EXPECT() *MockConnectionManagerMockRecorder
- func (m *MockConnectionManager) Peers() []Peer
- func (m *MockConnectionManager) RegisterObserver(callback StreamStateObserverFunc)
- func (m *MockConnectionManager) Start() error
- func (m *MockConnectionManager) Stop()
- type MockConnectionManagerMockRecorder
- func (mr *MockConnectionManagerMockRecorder) Connect(peerAddress, peerDID, delay interface{}) *gomock.Call
- func (mr *MockConnectionManagerMockRecorder) Contacts() *gomock.Call
- func (mr *MockConnectionManagerMockRecorder) Diagnostics() *gomock.Call
- func (mr *MockConnectionManagerMockRecorder) Peers() *gomock.Call
- func (mr *MockConnectionManagerMockRecorder) RegisterObserver(callback interface{}) *gomock.Call
- func (mr *MockConnectionManagerMockRecorder) Start() *gomock.Call
- func (mr *MockConnectionManagerMockRecorder) Stop() *gomock.Call
- type MockProtocol
- func (m *MockProtocol) Configure(peerID PeerID) error
- func (m *MockProtocol) Diagnostics() []core.DiagnosticResult
- func (m *MockProtocol) EXPECT() *MockProtocolMockRecorder
- func (m *MockProtocol) PeerDiagnostics() map[PeerID]Diagnostics
- func (m *MockProtocol) Start() error
- func (m *MockProtocol) Stop()
- func (m *MockProtocol) Version() int
- type MockProtocolMockRecorder
- func (mr *MockProtocolMockRecorder) Configure(peerID interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) Diagnostics() *gomock.Call
- func (mr *MockProtocolMockRecorder) PeerDiagnostics() *gomock.Call
- func (mr *MockProtocolMockRecorder) Start() *gomock.Call
- func (mr *MockProtocolMockRecorder) Stop() *gomock.Call
- func (mr *MockProtocolMockRecorder) Version() *gomock.Call
- type NutsCommURL
- type Peer
- type PeerID
- type Protocol
- type StreamState
- type StreamStateObserverFunc
Constants ¶
const NutsCommServiceType = "NutsComm"
NutsCommServiceType holds the DID document service type that specifies the Nuts network service address of the Nuts node.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionManager ¶
type ConnectionManager interface {
core.Diagnosable
// Connect attempts to make an outbound connection to the given peer, after the delay has expired.
// If the delay is 0 it will immediately start connecting. It will take the existing backoff into account when it is nil.
Connect(peerAddress string, peerDID did.DID, delay *time.Duration)
// Peers returns a slice containing the peers that are currently connected.
Peers() []Peer
// Contacts returns a slice containing the contacts that are currently known (to which we try to connect).
Contacts() []Contact
// RegisterObserver allows to register a callback function for stream state changes
RegisterObserver(callback StreamStateObserverFunc)
// Start instructs the ConnectionManager to start accepting connections and prepare to make outbound connections.
Start() error
// Stop shuts down the connections made by the ConnectionManager.
Stop()
}
ConnectionManager manages the connections to peers, making outbound connections if required. It also determines the network layout.
type Contact ¶
type Contact struct {
// Address holds the target address the connector is connecting to.
Address string
// DID holds the target DID for the given Address. Is empty for bootstrap nodes
DID did.DID
// Attempts holds the number of times the node tried to connect to the peer.
Attempts uint32
// LastAttempt holds the time of the last connection attempt.
LastAttempt *time.Time
// NextAttempt holds the time of the next connection attempt.
NextAttempt *time.Time
// Error holds the errors that occurred during the connection attempts.
Error *string
}
Contact holds statistics of an outbound connector.
type Diagnostics ¶
type Diagnostics struct {
// Uptime the uptime (time since the node started) in seconds.
Uptime time.Duration `json:"uptime"`
// Peers contains the peer IDs of the node's peers.
Peers []PeerID `json:"peers"`
// NumberOfTransactions contains the total number of transactions on the node's DAG.
NumberOfTransactions uint32 `json:"transactionNum"`
// SoftwareVersion contains an indication of the software version of the node. It's recommended to use a (Git) commit ID that uniquely resolves to a code revision, alternatively a semantic version could be used (e.g. 1.2.5).
SoftwareVersion string `json:"softwareVersion"`
// SoftwareID contains an indication of the vendor of the software of the node. For open source implementations it's recommended to specify URL to the public, open source repository.
// Proprietary implementations could specify the product's or vendor's name.
SoftwareID string `json:"softwareID"`
// Certificate contains the certificate presented by the peer during the TLS handshake.
Certificate string `json:"certificate"`
// NodeDID of the connection.
NodeDID string `json:"nodeDID"`
// Address is NutsComm on outbound, or IP for inbound connections.
Address string `json:"address"`
}
Diagnostics contains information that is shared to this node's peers on request.
type MockConnectionManager ¶
type MockConnectionManager struct {
// contains filtered or unexported fields
}
MockConnectionManager is a mock of ConnectionManager interface.
func NewMockConnectionManager ¶
func NewMockConnectionManager(ctrl *gomock.Controller) *MockConnectionManager
NewMockConnectionManager creates a new mock instance.
func (*MockConnectionManager) Contacts ¶
func (m *MockConnectionManager) Contacts() []Contact
Contacts mocks base method.
func (*MockConnectionManager) Diagnostics ¶
func (m *MockConnectionManager) Diagnostics() []core.DiagnosticResult
Diagnostics mocks base method.
func (*MockConnectionManager) EXPECT ¶
func (m *MockConnectionManager) EXPECT() *MockConnectionManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockConnectionManager) Peers ¶
func (m *MockConnectionManager) Peers() []Peer
Peers mocks base method.
func (*MockConnectionManager) RegisterObserver ¶
func (m *MockConnectionManager) RegisterObserver(callback StreamStateObserverFunc)
RegisterObserver mocks base method.
func (*MockConnectionManager) Start ¶
func (m *MockConnectionManager) Start() error
Start mocks base method.
type MockConnectionManagerMockRecorder ¶
type MockConnectionManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockConnectionManagerMockRecorder is the mock recorder for MockConnectionManager.
func (*MockConnectionManagerMockRecorder) Connect ¶
func (mr *MockConnectionManagerMockRecorder) Connect(peerAddress, peerDID, delay interface{}) *gomock.Call
Connect indicates an expected call of Connect.
func (*MockConnectionManagerMockRecorder) Contacts ¶
func (mr *MockConnectionManagerMockRecorder) Contacts() *gomock.Call
Contacts indicates an expected call of Contacts.
func (*MockConnectionManagerMockRecorder) Diagnostics ¶
func (mr *MockConnectionManagerMockRecorder) Diagnostics() *gomock.Call
Diagnostics indicates an expected call of Diagnostics.
func (*MockConnectionManagerMockRecorder) Peers ¶
func (mr *MockConnectionManagerMockRecorder) Peers() *gomock.Call
Peers indicates an expected call of Peers.
func (*MockConnectionManagerMockRecorder) RegisterObserver ¶
func (mr *MockConnectionManagerMockRecorder) RegisterObserver(callback interface{}) *gomock.Call
RegisterObserver indicates an expected call of RegisterObserver.
func (*MockConnectionManagerMockRecorder) Start ¶
func (mr *MockConnectionManagerMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start.
func (*MockConnectionManagerMockRecorder) Stop ¶
func (mr *MockConnectionManagerMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
type MockProtocol ¶
type MockProtocol struct {
// contains filtered or unexported fields
}
MockProtocol is a mock of Protocol interface.
func NewMockProtocol ¶
func NewMockProtocol(ctrl *gomock.Controller) *MockProtocol
NewMockProtocol creates a new mock instance.
func (*MockProtocol) Configure ¶
func (m *MockProtocol) Configure(peerID PeerID) error
Configure mocks base method.
func (*MockProtocol) Diagnostics ¶
func (m *MockProtocol) Diagnostics() []core.DiagnosticResult
Diagnostics mocks base method.
func (*MockProtocol) EXPECT ¶
func (m *MockProtocol) EXPECT() *MockProtocolMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProtocol) PeerDiagnostics ¶
func (m *MockProtocol) PeerDiagnostics() map[PeerID]Diagnostics
PeerDiagnostics mocks base method.
type MockProtocolMockRecorder ¶
type MockProtocolMockRecorder struct {
// contains filtered or unexported fields
}
MockProtocolMockRecorder is the mock recorder for MockProtocol.
func (*MockProtocolMockRecorder) Configure ¶
func (mr *MockProtocolMockRecorder) Configure(peerID interface{}) *gomock.Call
Configure indicates an expected call of Configure.
func (*MockProtocolMockRecorder) Diagnostics ¶
func (mr *MockProtocolMockRecorder) Diagnostics() *gomock.Call
Diagnostics indicates an expected call of Diagnostics.
func (*MockProtocolMockRecorder) PeerDiagnostics ¶
func (mr *MockProtocolMockRecorder) PeerDiagnostics() *gomock.Call
PeerDiagnostics indicates an expected call of PeerDiagnostics.
func (*MockProtocolMockRecorder) Start ¶
func (mr *MockProtocolMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start.
func (*MockProtocolMockRecorder) Stop ¶
func (mr *MockProtocolMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockProtocolMockRecorder) Version ¶
func (mr *MockProtocolMockRecorder) Version() *gomock.Call
Version indicates an expected call of Version.
type NutsCommURL ¶
NutsCommURL is the type which can be used to store a NutsComm endpoint in a DID Document. It contains the checks to validate if the endpoint is valid.
func (*NutsCommURL) UnmarshalJSON ¶
func (s *NutsCommURL) UnmarshalJSON(bytes []byte) error
type Peer ¶
type Peer struct {
// ID holds the unique identifier of the peer
ID PeerID `json:"id"`
// Address holds the remote address of the node we're actually connected to
Address string `json:"address"`
// NodeDID holds the DID that the peer uses to identify its node on the network.
// If Authenticated is true the NodeDID is verified.
NodeDID did.DID `json:"nodedid"`
// Authenticated is true when NodeDID is set and authentication is successful.
Authenticated bool `json:"authenticated"`
// Certificate presented by peer during TLS handshake.
Certificate *x509.Certificate `json:"-" yaml:"-"`
}
Peer holds the properties of a remote node we're connected to
func (Peer) CertificateAsPem ¶
type Protocol ¶
type Protocol interface {
// Configure configures the Protocol implementation, must be called before Start().
Configure(peerID PeerID) error
// Start starts the Protocol implementation.
Start() error
// Stop stops the Protocol implementation.
Stop()
// Diagnostics collects and returns diagnostical information on the protocol.
Diagnostics() []core.DiagnosticResult
// PeerDiagnostics collects and returns diagnostical information on the peers the protocol is communicating with.
PeerDiagnostics() map[PeerID]Diagnostics
// Version returns the version of the protocol
Version() int
}
Protocol is a self-contained process that can exchange network data (e.g. DAG transactions or private credentials) with other parties on the network.
type StreamState ¶
type StreamState string
StreamState is a type for defining connection states
const ( // StateConnected is passed to the connection observers when a stream state changed to connected StateConnected StreamState = "connected" // StateDisconnected is passed to the connection observers when a stream state changed to disconnected StateDisconnected StreamState = "disconnected" )
type StreamStateObserverFunc ¶
type StreamStateObserverFunc func(peer Peer, state StreamState, protocol Protocol)
StreamStateObserverFunc is a function that can be registered on the connection manager. If a stream state changes this callback will be called. It's called per protocol.