Documentation
¶
Overview ¶
Package grpc is a generated GoMock package.
Package grpc is a generated GoMock package.
Package grpc is a generated GoMock package.
Package grpc is a generated GoMock package.
Index ¶
- Variables
- func GetStreamMethod(serviceName string, stream grpc.StreamDesc) string
- func NewGRPCConnectionManager(config Config, nodeDIDResolver transport.NodeDIDResolver, ...) transport.ConnectionManager
- func RandomBackoff(min, max time.Duration) time.Duration
- func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer)
- type Authenticator
- type Backoff
- type ClientStream
- type Config
- type ConfigOption
- type Conn
- type Connection
- type ConnectionList
- type ConnectorsStats
- type MockAuthenticator
- type MockAuthenticatorMockRecorder
- type MockClientStream
- func (m *MockClientStream) CloseSend() error
- func (m *MockClientStream) Context() context.Context
- func (m *MockClientStream) EXPECT() *MockClientStreamMockRecorder
- func (m *MockClientStream) Header() (metadata.MD, error)
- func (m_2 *MockClientStream) RecvMsg(m interface{}) error
- func (m_2 *MockClientStream) SendMsg(m interface{}) error
- func (m *MockClientStream) Trailer() metadata.MD
- type MockClientStreamMockRecorder
- func (mr *MockClientStreamMockRecorder) CloseSend() *gomock.Call
- func (mr *MockClientStreamMockRecorder) Context() *gomock.Call
- func (mr *MockClientStreamMockRecorder) Header() *gomock.Call
- func (mr *MockClientStreamMockRecorder) RecvMsg(m interface{}) *gomock.Call
- func (mr *MockClientStreamMockRecorder) SendMsg(m interface{}) *gomock.Call
- func (mr *MockClientStreamMockRecorder) Trailer() *gomock.Call
- type MockConn
- type MockConnMockRecorder
- type MockConnection
- type MockConnectionList
- type MockConnectionListMockRecorder
- type MockConnectionMockRecorder
- type MockProtocol
- func (m *MockProtocol) Configure(peerID transport.PeerID) error
- func (m *MockProtocol) CreateClientStream(outgoingContext context.Context, grpcConn grpc.ClientConnInterface) (grpc.ClientStream, error)
- func (m *MockProtocol) CreateEnvelope() interface{}
- func (m *MockProtocol) Diagnostics() []core.DiagnosticResult
- func (m *MockProtocol) EXPECT() *MockProtocolMockRecorder
- func (m *MockProtocol) Handle(peer transport.Peer, envelope interface{}) error
- func (m *MockProtocol) MethodName() string
- func (m *MockProtocol) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
- func (m *MockProtocol) Register(registrar grpc.ServiceRegistrar, acceptor func(grpc.ServerStream) error, ...)
- func (m *MockProtocol) Start() error
- func (m *MockProtocol) Stop()
- func (m *MockProtocol) UnwrapMessage(envelope interface{}) interface{}
- func (m *MockProtocol) Version() int
- type MockProtocolMockRecorder
- func (mr *MockProtocolMockRecorder) Configure(peerID interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) CreateClientStream(outgoingContext, grpcConn interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) CreateEnvelope() *gomock.Call
- func (mr *MockProtocolMockRecorder) Diagnostics() *gomock.Call
- func (mr *MockProtocolMockRecorder) Handle(peer, envelope interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) MethodName() *gomock.Call
- func (mr *MockProtocolMockRecorder) PeerDiagnostics() *gomock.Call
- func (mr *MockProtocolMockRecorder) Register(registrar, acceptor, connectionList, connectionManager interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) Start() *gomock.Call
- func (mr *MockProtocolMockRecorder) Stop() *gomock.Call
- func (mr *MockProtocolMockRecorder) UnwrapMessage(envelope interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) Version() *gomock.Call
- type MockStream
- type MockStreamMockRecorder
- type Predicate
- type Protocol
- type Stream
- type StubConnection
- type StubConnectionList
- type StubStreamReceiver
- type TestClient
- type TestMessage
- type TestNodeDIDResolver
- type TestProtocol
- func (s TestProtocol) Configure(_ transport.PeerID) error
- func (s *TestProtocol) CreateClientStream(outgoingContext context.Context, grpcConn grpc.ClientConnInterface) (grpc.ClientStream, error)
- func (s *TestProtocol) CreateEnvelope() interface{}
- func (s TestProtocol) Diagnostics() []core.DiagnosticResult
- func (s *TestProtocol) DoStuff(serverStream Test_DoStuffServer) error
- func (s *TestProtocol) Handle(peer transport.Peer, envelope interface{}) error
- func (s *TestProtocol) MethodName() string
- func (s TestProtocol) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
- func (s *TestProtocol) Register(registrar grpc.ServiceRegistrar, acceptor func(stream grpc.ServerStream) error, ...)
- func (s TestProtocol) Start() error
- func (s TestProtocol) Stop()
- func (s *TestProtocol) UnwrapMessage(envelope interface{}) interface{}
- func (s *TestProtocol) Version() int
- type TestServer
- type Test_DoStuffClient
- type Test_DoStuffServer
- type UnimplementedTestServer
- type UnsafeTestServer
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyConnected = errors.New("already connected")
ErrAlreadyConnected indicates the node is already connected to the peer.
var ErrNoConnection = errors.New("no connection available")
ErrNoConnection can be used when no connectin is available but one is required.
var ErrNodeDIDAuthFailed = errors.New("nodeDID authentication failed")
ErrNodeDIDAuthFailed is the error message returned to the peer when the node DID it sent could not be authenticated. It is specified by RFC017.
var File_transport_grpc_testprotocol_proto protoreflect.FileDescriptor
var MaxMessageSizeInBytes = defaultMaxMessageSizeInBytes
MaxMessageSizeInBytes defines the maximum size of an in- or outbound gRPC/Protobuf message
var Test_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.Test", HandlerType: (*TestServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ { StreamName: "DoStuff", Handler: _Test_DoStuff_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "transport/grpc/testprotocol.proto", }
Test_ServiceDesc is the grpc.ServiceDesc for Test service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func GetStreamMethod ¶
func GetStreamMethod(serviceName string, stream grpc.StreamDesc) string
GetStreamMethod formats the method name for the given stream.
func NewGRPCConnectionManager ¶
func NewGRPCConnectionManager(config Config, nodeDIDResolver transport.NodeDIDResolver, authenticator Authenticator, protocols ...transport.Protocol) transport.ConnectionManager
NewGRPCConnectionManager creates a new ConnectionManager that accepts/creates connections which communicate using the given protocols.
func RandomBackoff ¶
RandomBackoff returns a random time.Duration which lies between the given (inclusive) min/max bounds. It can be used to get a random, one-off backoff.
func RegisterTestServer ¶
func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer)
Types ¶
type Authenticator ¶
type Authenticator interface {
// Authenticate verifies the given nodeDID using the given grpc.Peer.
// When authentication is successful adds authenticated peer info to the given transport.Peer and returns it.
// When authentication fails, an error is returned.
Authenticate(nodeDID did.DID, grpcPeer grpcPeer.Peer, peer transport.Peer) (transport.Peer, error)
}
Authenticator verifies node identities.
func NewDummyAuthenticator ¶
func NewDummyAuthenticator(serviceResolver doc.ServiceResolver) Authenticator
NewDummyAuthenticator creates an Authenticator that does not verify node identities
func NewTLSAuthenticator ¶
func NewTLSAuthenticator(serviceResolver doc.ServiceResolver) Authenticator
NewTLSAuthenticator creates an Authenticator that verifies node identities using TLS certificates.
type Backoff ¶
type Backoff interface {
// Reset resets the internal counters of the Backoff and should be called after a successful call.
Reset()
// Backoff returns the waiting time before the call should be retried, and should be called after a failed call.
Backoff() time.Duration
}
Backoff defines an API for delaying calls (or connections) to a remote system when its unresponsive, to avoid flooding both local and remote system. When a call fails Backoff() must be called, which returns the waiting time before the action should be retried. When the call succeeds Reset() and the Backoff is stored for re-use, Reset() should be called to make sure to reset the internal counters.
type ClientStream ¶
type ClientStream interface {
grpc.ClientStream
}
ClientStream is a wrapper around grpc.ClientStream
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds values for configuring the gRPC ConnectionManager.
func NewBufconnConfig ¶
NewBufconnConfig creates a new Config like NewConfig, but configures an in-memory bufconn listener instead of a TCP listener.
func NewConfig ¶
func NewConfig(grpcAddress string, peerID networkTypes.PeerID, options ...ConfigOption) Config
NewConfig creates a new Config, used for configuring a gRPC ConnectionManager.
type ConfigOption ¶
type ConfigOption func(config *Config)
ConfigOption is used to build Config.
func WithBufconnDialer ¶
func WithBufconnDialer(listener *bufconn.Listener) ConfigOption
WithBufconnDialer can be used to redirect outbound connections to a predetermined bufconn listener.
func WithTLS ¶
func WithTLS(clientCertificate tls.Certificate, trustStore *core.TrustStore, maxCRLValidityDays int) ConfigOption
WithTLS enables TLS for gRPC ConnectionManager.
type Conn ¶
type Conn interface {
grpc.ClientConnInterface
}
Conn is a wrapper around grpc.ClientConnInterface
type Connection ¶
type Connection interface {
// Send tries to send the given message over the stream of the given protocol.
// If there's no active stream for the protocol, or something else goes wrong, an error is returned.
Send(protocol Protocol, envelope interface{}) error
// Peer returns the associated peer information of this connection. If the connection is not active, it will return an empty peer.
Peer() transport.Peer
// IsConnected returns whether the connection is active or not.
IsConnected() bool
// contains filtered or unexported methods
}
Connection is created by grpcConnectionManager to register a connection to a peer. The connection can be either inbound or outbound. The presence of a Connection for a peer doesn't imply there's an actual connection, because it might still be trying to establish an outbound connection to the given peer.
type ConnectionList ¶
type ConnectionList interface {
// Get returns the first Connection which matches the predicates (using AND)
// If there's no match, nil is returned.
Get(query ...Predicate) Connection
// All returns the list of connections.
All() []Connection
}
ConnectionList provides an API for protocols to query the ConnectionManager's connections.
type ConnectorsStats ¶
type ConnectorsStats []transport.ConnectorStats
ConnectorsStats holds statistics on outbound connectors.
func (ConnectorsStats) Name ¶
func (a ConnectorsStats) Name() string
func (ConnectorsStats) Result ¶
func (a ConnectorsStats) Result() interface{}
func (ConnectorsStats) String ¶
func (a ConnectorsStats) String() string
type MockAuthenticator ¶
type MockAuthenticator struct {
// contains filtered or unexported fields
}
MockAuthenticator is a mock of Authenticator interface.
func NewMockAuthenticator ¶
func NewMockAuthenticator(ctrl *gomock.Controller) *MockAuthenticator
NewMockAuthenticator creates a new mock instance.
func (*MockAuthenticator) Authenticate ¶
func (m *MockAuthenticator) Authenticate(nodeDID did.DID, grpcPeer peer.Peer, peer transport.Peer) (transport.Peer, error)
Authenticate mocks base method.
func (*MockAuthenticator) EXPECT ¶
func (m *MockAuthenticator) EXPECT() *MockAuthenticatorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockAuthenticatorMockRecorder ¶
type MockAuthenticatorMockRecorder struct {
// contains filtered or unexported fields
}
MockAuthenticatorMockRecorder is the mock recorder for MockAuthenticator.
func (*MockAuthenticatorMockRecorder) Authenticate ¶
func (mr *MockAuthenticatorMockRecorder) Authenticate(nodeDID, grpcPeer, peer interface{}) *gomock.Call
Authenticate indicates an expected call of Authenticate.
type MockClientStream ¶
type MockClientStream struct {
// contains filtered or unexported fields
}
MockClientStream is a mock of ClientStream interface.
func NewMockClientStream ¶
func NewMockClientStream(ctrl *gomock.Controller) *MockClientStream
NewMockClientStream creates a new mock instance.
func (*MockClientStream) CloseSend ¶
func (m *MockClientStream) CloseSend() error
CloseSend mocks base method.
func (*MockClientStream) Context ¶
func (m *MockClientStream) Context() context.Context
Context mocks base method.
func (*MockClientStream) EXPECT ¶
func (m *MockClientStream) EXPECT() *MockClientStreamMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockClientStream) Header ¶
func (m *MockClientStream) Header() (metadata.MD, error)
Header mocks base method.
func (*MockClientStream) RecvMsg ¶
func (m_2 *MockClientStream) RecvMsg(m interface{}) error
RecvMsg mocks base method.
func (*MockClientStream) SendMsg ¶
func (m_2 *MockClientStream) SendMsg(m interface{}) error
SendMsg mocks base method.
func (*MockClientStream) Trailer ¶
func (m *MockClientStream) Trailer() metadata.MD
Trailer mocks base method.
type MockClientStreamMockRecorder ¶
type MockClientStreamMockRecorder struct {
// contains filtered or unexported fields
}
MockClientStreamMockRecorder is the mock recorder for MockClientStream.
func (*MockClientStreamMockRecorder) CloseSend ¶
func (mr *MockClientStreamMockRecorder) CloseSend() *gomock.Call
CloseSend indicates an expected call of CloseSend.
func (*MockClientStreamMockRecorder) Context ¶
func (mr *MockClientStreamMockRecorder) Context() *gomock.Call
Context indicates an expected call of Context.
func (*MockClientStreamMockRecorder) Header ¶
func (mr *MockClientStreamMockRecorder) Header() *gomock.Call
Header indicates an expected call of Header.
func (*MockClientStreamMockRecorder) RecvMsg ¶
func (mr *MockClientStreamMockRecorder) RecvMsg(m interface{}) *gomock.Call
RecvMsg indicates an expected call of RecvMsg.
func (*MockClientStreamMockRecorder) SendMsg ¶
func (mr *MockClientStreamMockRecorder) SendMsg(m interface{}) *gomock.Call
SendMsg indicates an expected call of SendMsg.
func (*MockClientStreamMockRecorder) Trailer ¶
func (mr *MockClientStreamMockRecorder) Trailer() *gomock.Call
Trailer indicates an expected call of Trailer.
type MockConn ¶
type MockConn struct {
// contains filtered or unexported fields
}
MockConn is a mock of Conn interface.
func NewMockConn ¶
func NewMockConn(ctrl *gomock.Controller) *MockConn
NewMockConn creates a new mock instance.
func (*MockConn) EXPECT ¶
func (m *MockConn) EXPECT() *MockConnMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockConn) Invoke ¶
func (m *MockConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...grpc.CallOption) error
Invoke mocks base method.
func (*MockConn) NewStream ¶
func (m *MockConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
NewStream mocks base method.
type MockConnMockRecorder ¶
type MockConnMockRecorder struct {
// contains filtered or unexported fields
}
MockConnMockRecorder is the mock recorder for MockConn.
func (*MockConnMockRecorder) Invoke ¶
func (mr *MockConnMockRecorder) Invoke(ctx, method, args, reply interface{}, opts ...interface{}) *gomock.Call
Invoke indicates an expected call of Invoke.
func (*MockConnMockRecorder) NewStream ¶
func (mr *MockConnMockRecorder) NewStream(ctx, desc, method interface{}, opts ...interface{}) *gomock.Call
NewStream indicates an expected call of NewStream.
type MockConnection ¶
type MockConnection struct {
// contains filtered or unexported fields
}
MockConnection is a mock of Connection interface.
func NewMockConnection ¶
func NewMockConnection(ctrl *gomock.Controller) *MockConnection
NewMockConnection creates a new mock instance.
func (*MockConnection) EXPECT ¶
func (m *MockConnection) EXPECT() *MockConnectionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockConnection) IsConnected ¶
func (m *MockConnection) IsConnected() bool
IsConnected mocks base method.
func (*MockConnection) Peer ¶
func (m *MockConnection) Peer() transport.Peer
Peer mocks base method.
func (*MockConnection) Send ¶
func (m *MockConnection) Send(protocol Protocol, envelope interface{}) error
Send mocks base method.
type MockConnectionList ¶
type MockConnectionList struct {
// contains filtered or unexported fields
}
MockConnectionList is a mock of ConnectionList interface.
func NewMockConnectionList ¶
func NewMockConnectionList(ctrl *gomock.Controller) *MockConnectionList
NewMockConnectionList creates a new mock instance.
func (*MockConnectionList) All ¶
func (m *MockConnectionList) All() []Connection
All mocks base method.
func (*MockConnectionList) EXPECT ¶
func (m *MockConnectionList) EXPECT() *MockConnectionListMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockConnectionList) Get ¶
func (m *MockConnectionList) Get(query ...Predicate) Connection
Get mocks base method.
type MockConnectionListMockRecorder ¶
type MockConnectionListMockRecorder struct {
// contains filtered or unexported fields
}
MockConnectionListMockRecorder is the mock recorder for MockConnectionList.
func (*MockConnectionListMockRecorder) All ¶
func (mr *MockConnectionListMockRecorder) All() *gomock.Call
All indicates an expected call of All.
func (*MockConnectionListMockRecorder) Get ¶
func (mr *MockConnectionListMockRecorder) Get(query ...interface{}) *gomock.Call
Get indicates an expected call of Get.
type MockConnectionMockRecorder ¶
type MockConnectionMockRecorder struct {
// contains filtered or unexported fields
}
MockConnectionMockRecorder is the mock recorder for MockConnection.
func (*MockConnectionMockRecorder) IsConnected ¶
func (mr *MockConnectionMockRecorder) IsConnected() *gomock.Call
IsConnected indicates an expected call of IsConnected.
func (*MockConnectionMockRecorder) Peer ¶
func (mr *MockConnectionMockRecorder) Peer() *gomock.Call
Peer indicates an expected call of Peer.
func (*MockConnectionMockRecorder) Send ¶
func (mr *MockConnectionMockRecorder) Send(protocol, envelope interface{}) *gomock.Call
Send indicates an expected call of Send.
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 transport.PeerID) error
Configure mocks base method.
func (*MockProtocol) CreateClientStream ¶
func (m *MockProtocol) CreateClientStream(outgoingContext context.Context, grpcConn grpc.ClientConnInterface) (grpc.ClientStream, error)
CreateClientStream mocks base method.
func (*MockProtocol) CreateEnvelope ¶
func (m *MockProtocol) CreateEnvelope() interface{}
CreateEnvelope 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) Handle ¶
func (m *MockProtocol) Handle(peer transport.Peer, envelope interface{}) error
Handle mocks base method.
func (*MockProtocol) MethodName ¶
func (m *MockProtocol) MethodName() string
MethodName mocks base method.
func (*MockProtocol) PeerDiagnostics ¶
func (m *MockProtocol) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
PeerDiagnostics mocks base method.
func (*MockProtocol) Register ¶
func (m *MockProtocol) Register(registrar grpc.ServiceRegistrar, acceptor func(grpc.ServerStream) error, connectionList ConnectionList, connectionManager transport.ConnectionManager)
Register mocks base method.
func (*MockProtocol) UnwrapMessage ¶
func (m *MockProtocol) UnwrapMessage(envelope interface{}) interface{}
UnwrapMessage 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) CreateClientStream ¶
func (mr *MockProtocolMockRecorder) CreateClientStream(outgoingContext, grpcConn interface{}) *gomock.Call
CreateClientStream indicates an expected call of CreateClientStream.
func (*MockProtocolMockRecorder) CreateEnvelope ¶
func (mr *MockProtocolMockRecorder) CreateEnvelope() *gomock.Call
CreateEnvelope indicates an expected call of CreateEnvelope.
func (*MockProtocolMockRecorder) Diagnostics ¶
func (mr *MockProtocolMockRecorder) Diagnostics() *gomock.Call
Diagnostics indicates an expected call of Diagnostics.
func (*MockProtocolMockRecorder) Handle ¶
func (mr *MockProtocolMockRecorder) Handle(peer, envelope interface{}) *gomock.Call
Handle indicates an expected call of Handle.
func (*MockProtocolMockRecorder) MethodName ¶
func (mr *MockProtocolMockRecorder) MethodName() *gomock.Call
MethodName indicates an expected call of MethodName.
func (*MockProtocolMockRecorder) PeerDiagnostics ¶
func (mr *MockProtocolMockRecorder) PeerDiagnostics() *gomock.Call
PeerDiagnostics indicates an expected call of PeerDiagnostics.
func (*MockProtocolMockRecorder) Register ¶
func (mr *MockProtocolMockRecorder) Register(registrar, acceptor, connectionList, connectionManager interface{}) *gomock.Call
Register indicates an expected call of Register.
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) UnwrapMessage ¶
func (mr *MockProtocolMockRecorder) UnwrapMessage(envelope interface{}) *gomock.Call
UnwrapMessage indicates an expected call of UnwrapMessage.
func (*MockProtocolMockRecorder) Version ¶
func (mr *MockProtocolMockRecorder) Version() *gomock.Call
Version indicates an expected call of Version.
type MockStream ¶
type MockStream struct {
// contains filtered or unexported fields
}
MockStream is a mock of Stream interface.
func NewMockStream ¶
func NewMockStream(ctrl *gomock.Controller) *MockStream
NewMockStream creates a new mock instance.
func (*MockStream) Context ¶
func (m *MockStream) Context() context.Context
Context mocks base method.
func (*MockStream) EXPECT ¶
func (m *MockStream) EXPECT() *MockStreamMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStream) RecvMsg ¶
func (m_2 *MockStream) RecvMsg(m interface{}) error
RecvMsg mocks base method.
func (*MockStream) SendMsg ¶
func (m_2 *MockStream) SendMsg(m interface{}) error
SendMsg mocks base method.
type MockStreamMockRecorder ¶
type MockStreamMockRecorder struct {
// contains filtered or unexported fields
}
MockStreamMockRecorder is the mock recorder for MockStream.
func (*MockStreamMockRecorder) Context ¶
func (mr *MockStreamMockRecorder) Context() *gomock.Call
Context indicates an expected call of Context.
func (*MockStreamMockRecorder) RecvMsg ¶
func (mr *MockStreamMockRecorder) RecvMsg(m interface{}) *gomock.Call
RecvMsg indicates an expected call of RecvMsg.
func (*MockStreamMockRecorder) SendMsg ¶
func (mr *MockStreamMockRecorder) SendMsg(m interface{}) *gomock.Call
SendMsg indicates an expected call of SendMsg.
type Predicate ¶
type Predicate interface {
Match(conn Connection) bool
}
Predicate matches the connection based on a condition
func ByConnected ¶
func ByConnected() Predicate
ByConnected filters the connection by the connection state (if it's connected)
func ByNotConnected ¶
func ByNotConnected() Predicate
ByNotConnected filters the connection by the connection state (if it's not connected)
type Protocol ¶
type Protocol interface {
transport.Protocol
// MethodName returns the fully qualified name of the gRPC stream.
MethodName() string
// CreateClientStream creates a new client for the gRPC stream.
CreateClientStream(outgoingContext context.Context, grpcConn grpc.ClientConnInterface) (grpc.ClientStream, error)
// Register registers the protocol implementation.
Register(registrar grpc.ServiceRegistrar, acceptor func(stream grpc.ServerStream) error, connectionList ConnectionList, connectionManager transport.ConnectionManager)
// CreateEnvelope is called to create a new, empty envelope, required for receiving messages.
CreateEnvelope() interface{}
// Handle is called with to let the protocol handle a received message.
Handle(peer transport.Peer, envelope interface{}) error
// UnwrapMessage is used to extract the inner message from the envelope.
UnwrapMessage(envelope interface{}) interface{}
}
Protocol defines the API for streaming gRPC protocol implementations.
type Stream ¶
type Stream interface {
Context() context.Context
SendMsg(m interface{}) error
RecvMsg(m interface{}) error
}
Stream bundles common functions from grpc.ServerStream and grpc.ClientStream, providing a common interface.
type StubConnection ¶
type StubConnection struct {
Open bool
NodeDID did.DID
SentMsgs []interface{}
PeerID transport.PeerID
}
StubConnection is a stub implementation of the Connection interface
func (StubConnection) IsConnected ¶
func (s StubConnection) IsConnected() bool
IsConnected returns true if the connection is connected
func (StubConnection) Peer ¶
func (s StubConnection) Peer() transport.Peer
Peer returns the peer information of the connection
func (*StubConnection) Send ¶
func (s *StubConnection) Send(_ Protocol, envelope interface{}) error
Send sends a message to the connection
type StubConnectionList ¶
type StubConnectionList struct {
Conn *StubConnection
}
StubConnectionList is a stub implementation of the transport.ConnectionList interface
func (StubConnectionList) All ¶
func (s StubConnectionList) All() []Connection
All returns all connections
func (*StubConnectionList) Get ¶
func (s *StubConnectionList) Get(query ...Predicate) Connection
Get returns the connection for the given query
type StubStreamReceiver ¶
StubStreamReceiver is a stub implementation of the transport.StreamReceiver interface
func (*StubStreamReceiver) RecvMsg ¶
func (s *StubStreamReceiver) RecvMsg(m interface{}) error
RecvMsg is a stub implementation of the transport.StreamReceiver interface
type TestClient ¶
type TestClient interface {
DoStuff(ctx context.Context, opts ...grpc.CallOption) (Test_DoStuffClient, error)
}
TestClient is the client API for Test service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewTestClient ¶
func NewTestClient(cc grpc.ClientConnInterface) TestClient
type TestMessage ¶
type TestMessage struct {
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
// contains filtered or unexported fields
}
func (*TestMessage) Descriptor
deprecated
func (*TestMessage) Descriptor() ([]byte, []int)
Deprecated: Use TestMessage.ProtoReflect.Descriptor instead.
func (*TestMessage) GetData ¶
func (x *TestMessage) GetData() []byte
func (*TestMessage) ProtoMessage ¶
func (*TestMessage) ProtoMessage()
func (*TestMessage) ProtoReflect ¶
func (x *TestMessage) ProtoReflect() protoreflect.Message
func (*TestMessage) Reset ¶
func (x *TestMessage) Reset()
func (*TestMessage) String ¶
func (x *TestMessage) String() string
type TestNodeDIDResolver ¶
type TestNodeDIDResolver struct {
// contains filtered or unexported fields
}
TestNodeDIDResolver is a stub implementation of the transport.DIDResolver interface
type TestProtocol ¶
type TestProtocol struct {
// contains filtered or unexported fields
}
TestProtocol is an implementation of a gRPC-based protocol for testing.
func (*TestProtocol) CreateClientStream ¶
func (s *TestProtocol) CreateClientStream(outgoingContext context.Context, grpcConn grpc.ClientConnInterface) (grpc.ClientStream, error)
CreateClientStream creates a gRPC ClientStream.
func (*TestProtocol) CreateEnvelope ¶
func (s *TestProtocol) CreateEnvelope() interface{}
CreateEnvelope creates an empty test message.
func (TestProtocol) Diagnostics ¶
func (s TestProtocol) Diagnostics() []core.DiagnosticResult
func (*TestProtocol) DoStuff ¶
func (s *TestProtocol) DoStuff(serverStream Test_DoStuffServer) error
func (*TestProtocol) Handle ¶
func (s *TestProtocol) Handle(peer transport.Peer, envelope interface{}) error
Handle is not implemented.
func (*TestProtocol) MethodName ¶
func (s *TestProtocol) MethodName() string
MethodName returns the gRPC method name.
func (TestProtocol) PeerDiagnostics ¶
func (s TestProtocol) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
func (*TestProtocol) Register ¶
func (s *TestProtocol) Register(registrar grpc.ServiceRegistrar, acceptor func(stream grpc.ServerStream) error, _ ConnectionList, _ transport.ConnectionManager)
Register registers the test protocol on the gRPC server.
func (TestProtocol) Start ¶
func (s TestProtocol) Start() error
func (TestProtocol) Stop ¶
func (s TestProtocol) Stop()
func (*TestProtocol) UnwrapMessage ¶
func (s *TestProtocol) UnwrapMessage(envelope interface{}) interface{}
UnwrapMessage is not implemented.
func (*TestProtocol) Version ¶
func (s *TestProtocol) Version() int
type TestServer ¶
type TestServer interface {
DoStuff(Test_DoStuffServer) error
}
TestServer is the server API for Test service. All implementations should embed UnimplementedTestServer for forward compatibility
type Test_DoStuffClient ¶
type Test_DoStuffClient interface {
Send(*TestMessage) error
Recv() (*TestMessage, error)
grpc.ClientStream
}
type Test_DoStuffServer ¶
type Test_DoStuffServer interface {
Send(*TestMessage) error
Recv() (*TestMessage, error)
grpc.ServerStream
}
type UnimplementedTestServer ¶
type UnimplementedTestServer struct {
}
UnimplementedTestServer should be embedded to have forward compatible implementations.
func (UnimplementedTestServer) DoStuff ¶
func (UnimplementedTestServer) DoStuff(Test_DoStuffServer) error
type UnsafeTestServer ¶
type UnsafeTestServer interface {
// contains filtered or unexported methods
}
UnsafeTestServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TestServer will result in compilation errors.