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 ¶
- Constants
- Variables
- func GetStreamMethod(serviceName string, stream grpc.StreamDesc) string
- func NewClientTLSConfig(clientCert *tls.Certificate, trustStore *x509.CertPool, ...) (*tls.Config, error)
- func NewGRPCConnectionManager(config Config, connectionStore stoabs.KVStore, nodeDID did.DID, ...) (*grpcConnectionManager, error)
- func RandomBackoff(min, max time.Duration) time.Duration
- func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer)
- func SetPeerID(t *testing.T, manager transport.ConnectionManager, id transport.PeerID)
- type AddressBook
- type Authenticator
- type Backoff
- type ClientStream
- type Config
- type ConfigOption
- func WithBackoff(value func() Backoff) ConfigOption
- func WithConnectionTimeout(value time.Duration) ConfigOption
- func WithIdleTimeout(value time.Duration) ConfigOption
- func WithTLS(clientCertificate tls.Certificate, trustStore *core.TrustStore, ...) ConfigOption
- func WithTLSOffloading(clientCertHeaderName string) ConfigOption
- type Conn
- type Connection
- type ConnectionList
- 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) GetMessageType(envelope interface{}) string
- func (m *MockProtocol) Handle(connection Connection, 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) GetMessageType(envelope interface{}) *gomock.Call
- func (mr *MockProtocolMockRecorder) Handle(connection, 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
- func (s *StubConnection) ID() transport.PeerID
- func (s *StubConnection) IsAuthenticated() bool
- func (s *StubConnection) IsConnected() bool
- func (s *StubConnection) IsProtocolConnected(_ Protocol) bool
- func (s *StubConnection) Peer() transport.Peer
- func (s *StubConnection) Send(_ Protocol, envelope interface{}, _ bool) error
- func (s *StubConnection) SetErrorStatus(_ *status.Status)
- type StubConnectionList
- type TestClient
- type TestMessage
- 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) GetMessageType(envelope interface{}) string
- func (s *TestProtocol) Handle(connection Connection, 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 ¶
const OutboxHardLimit = 5000
OutboxHardLimit defines how many outgoing messages may be queued per protocol this is the hard limit of the underlying channel
const (
Test_DoStuff_FullMethodName = "/grpc.Test/DoStuff"
)
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 connection is available but one is required.
var ErrNodeDIDAuthFailed = status.Error(codes.Unauthenticated, "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 ErrUnexpectedNodeDID = fmt.Errorf("call answered by other node DID than expected: %w", ErrNodeDIDAuthFailed)
ErrUnexpectedNodeDID is the error used in outbound calling to signal that the peer sent a different NodeDID than expected. The DID has moved on, do not call it again until notified of its new address.
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 NewClientTLSConfig ¶
func NewClientTLSConfig(clientCert *tls.Certificate, trustStore *x509.CertPool, pkiValidator pki.Validator) (*tls.Config, error)
NewClientTLSConfig returns the network grpc client tls.Config
func NewGRPCConnectionManager ¶
func NewGRPCConnectionManager(config Config, connectionStore stoabs.KVStore, nodeDID did.DID, authenticator Authenticator, protocols ...transport.Protocol) (*grpcConnectionManager, error)
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 boundedRandomBackoff.
func RegisterTestServer ¶
func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer)
Types ¶
type AddressBook ¶
type AddressBook interface {
// contains filtered or unexported methods
}
AddressBook provides an API for protocols to query the ConnectionManager's known addresses.
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, peer transport.Peer) (transport.Peer, error)
}
Authenticator verifies node identities.
func NewDummyAuthenticator ¶
func NewDummyAuthenticator(_ types.ServiceResolver) Authenticator
NewDummyAuthenticator creates an Authenticator that does not verify node identities
func NewTLSAuthenticator ¶
func NewTLSAuthenticator(serviceResolver types.ServiceResolver) Authenticator
NewTLSAuthenticator creates an Authenticator that verifies node identities using TLS certificates.
type Backoff ¶
type Backoff interface {
// Reset the internal counters of the Backoff to the given value.
Reset(value time.Duration)
// Backoff returns the waiting time before the call should be retried, and should be called after a failed call.
Backoff() time.Duration
// Value returns the last backoff value returned by Backoff().
Value() time.Duration
// Max returns the upper bound of the values Backoff() can return.
Max() time.Duration
// Expired returns true if the backoff period has passed.
Expired() bool
}
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.
func NewPersistedBackoff ¶
NewPersistedBackoff wraps another backoff and stores the last value returned by Backoff() in BBolt. It reads the last backoff value from the DB and returns it as the first value of the Backoff. id is the key the backoff will be stored under in the DB.
func NewSyncedBackoff ¶
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 NewConfig ¶
func NewConfig(grpcAddress string, peerID networkTypes.PeerID, options ...ConfigOption) (Config, error)
NewConfig creates a new Config, used for configuring a gRPC ConnectionManager.
type ConfigOption ¶
func WithBackoff ¶
func WithBackoff(value func() Backoff) ConfigOption
func WithConnectionTimeout ¶
func WithConnectionTimeout(value time.Duration) ConfigOption
WithConnectionTimeout specifies the connection timeout for outbound connection attempts.
func WithIdleTimeout ¶
func WithIdleTimeout(value time.Duration) ConfigOption
WithIdleTimeout specifies the period without any received message after which a connection is closed. Zero disables the check.
func WithTLS ¶
func WithTLS(clientCertificate tls.Certificate, trustStore *core.TrustStore, pkiValidator pki.Validator) ConfigOption
WithTLS enables TLS for gRPC ConnectionManager.
func WithTLSOffloading ¶
func WithTLSOffloading(clientCertHeaderName string) ConfigOption
WithTLSOffloading enables TLS for outgoing connections, but is offloaded for incoming connections. It MUST be used in conjunction, but after with WithTLS.
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.
// A sender may specify ignoreSoftLimit=true to allow extra messages to be sent.
// This is needed to finish sending a TransactionList that falls within a single page.
Send(protocol Protocol, envelope interface{}, ignoreSoftLimit bool) error
// Peer returns the associated peer information of this connection.
Peer() transport.Peer
// IsConnected returns whether the connection is active or not.
IsConnected() bool
// IsAuthenticated returns whether teh given connection is authenticated.
IsAuthenticated() 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
// AllMatching returns the list of connections which match the predicates (using AND).
AllMatching(query ...Predicate) []Connection
}
ConnectionList provides an API for protocols to query the ConnectionManager's connections.
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, 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, 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) IsAuthenticated ¶
func (m *MockConnection) IsAuthenticated() bool
IsAuthenticated mocks base method.
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.
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) AllMatching ¶
func (m *MockConnectionList) AllMatching(query ...Predicate) []Connection
AllMatching 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) AllMatching ¶
func (mr *MockConnectionListMockRecorder) AllMatching(query ...interface{}) *gomock.Call
AllMatching indicates an expected call of AllMatching.
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) IsAuthenticated ¶
func (mr *MockConnectionMockRecorder) IsAuthenticated() *gomock.Call
IsAuthenticated indicates an expected call of IsAuthenticated.
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, ignoreSoftLimit 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) GetMessageType ¶
func (m *MockProtocol) GetMessageType(envelope interface{}) string
GetMessageType mocks base method.
func (*MockProtocol) Handle ¶
func (m *MockProtocol) Handle(connection Connection, 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) GetMessageType ¶
func (mr *MockProtocolMockRecorder) GetMessageType(envelope interface{}) *gomock.Call
GetMessageType indicates an expected call of GetMessageType.
func (*MockProtocolMockRecorder) Handle ¶
func (mr *MockProtocolMockRecorder) Handle(connection, 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 ByAuthenticated ¶
func ByAuthenticated() Predicate
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(connection Connection, envelope interface{}) error
// UnwrapMessage is used to extract the inner message from the envelope.
UnwrapMessage(envelope interface{}) interface{}
// GetMessageType returns a string key identifying the message type.
GetMessageType(envelope interface{}) string
}
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
Authenticated bool
Address string
Certificate *x509.Certificate
// contains filtered or unexported fields
}
StubConnection is a stub implementation of the Connection interface
func NewStubConnection ¶
func NewStubConnection(peer transport.Peer) *StubConnection
func (*StubConnection) ID ¶
func (s *StubConnection) ID() transport.PeerID
func (*StubConnection) IsAuthenticated ¶
func (s *StubConnection) IsAuthenticated() bool
IsAuthenticated returns whether teh given connection is authenticated.
func (*StubConnection) IsConnected ¶
func (s *StubConnection) IsConnected() bool
IsConnected returns true if the connection is connected
func (*StubConnection) IsProtocolConnected ¶
func (s *StubConnection) IsProtocolConnected(_ Protocol) bool
IsProtocolConnected returns true if the connection is connected for the given protocol
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{}, _ bool) error
Send sends a message to the connection
func (*StubConnection) SetErrorStatus ¶
func (s *StubConnection) SetErrorStatus(_ *status.Status)
type StubConnectionList ¶
type StubConnectionList struct {
Conn *StubConnection
}
StubConnectionList is a stub implementation of the transport.ConnectionList interface
func NewStubConnectionList ¶
func NewStubConnectionList(peer transport.Peer) *StubConnectionList
NewStubConnectionList returns a StubConnectionList with a connection to the provided transport.Peer
func (StubConnectionList) All ¶
func (s StubConnectionList) All() []Connection
All returns all connections
func (StubConnectionList) AllMatching ¶
func (s StubConnectionList) AllMatching(_ ...Predicate) []Connection
AllMatching returns all connections
func (*StubConnectionList) Get ¶
func (s *StubConnectionList) Get(query ...Predicate) Connection
Get returns the connection for the given query
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 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) GetMessageType ¶
func (s *TestProtocol) GetMessageType(envelope interface{}) string
func (*TestProtocol) Handle ¶
func (s *TestProtocol) Handle(connection Connection, 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.
Source Files
¶
- addressbook.go
- authenticator.go
- authenticator_mock.go
- backoff.go
- config.go
- connection.go
- connection_list.go
- connection_list_mock.go
- connection_manager.go
- connection_mock.go
- interface.go
- interface_mock.go
- ip_interceptor.go
- predicate.go
- stats.go
- test.go
- testprotocol.pb.go
- testprotocol_grpc.pb.go
- testprotocol_impl.pb.go
- tls_offloading.go
- util.go