Documentation ¶
Index ¶
- Variables
- func RegisterGrpcTransportServer(s grpc.ServiceRegistrar, srv GrpcTransportServer)
- type ByeBye
- type GrpcMessage
- func (*GrpcMessage) Descriptor() ([]byte, []int)deprecated
- func (x *GrpcMessage) GetMsg() *messagepb.Message
- func (x *GrpcMessage) GetSender() string
- func (*GrpcMessage) ProtoMessage()
- func (x *GrpcMessage) ProtoReflect() protoreflect.Message
- func (x *GrpcMessage) Reset()
- func (x *GrpcMessage) String() string
- type GrpcTransportClient
- type GrpcTransportServer
- type GrpcTransport_ListenClient
- type GrpcTransport_ListenServer
- type Transport
- func (gt *Transport) ApplyEvents(ctx context.Context, eventList *events.EventList) error
- func (gt *Transport) CloseOldConnections(newNodes *trantorpbtypes.Membership)
- func (gt *Transport) Connect(membership *trantorpbtypes.Membership)
- func (gt *Transport) EventsOut() <-chan *events.EventList
- func (gt *Transport) ImplementsModule()
- func (gt *Transport) Listen(srv GrpcTransport_ListenServer) error
- func (gt *Transport) Send(dest t.NodeID, msg *messagepb.Message) error
- func (gt *Transport) ServerError() error
- func (gt *Transport) Start() error
- func (gt *Transport) Stop()
- func (gt *Transport) WaitFor(_ int) error
- type UnimplementedGrpcTransportServer
- type UnsafeGrpcTransportServer
Constants ¶
This section is empty.
Variables ¶
var File_net_grpc_grpctransport_proto protoreflect.FileDescriptor
var GrpcTransport_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpctransport.GrpcTransport", HandlerType: (*GrpcTransportServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ { StreamName: "Listen", Handler: _GrpcTransport_Listen_Handler, ClientStreams: true, }, }, Metadata: "net/grpc/grpctransport.proto", }
GrpcTransport_ServiceDesc is the grpc.ServiceDesc for GrpcTransport service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterGrpcTransportServer ¶
func RegisterGrpcTransportServer(s grpc.ServiceRegistrar, srv GrpcTransportServer)
Types ¶
type ByeBye ¶
type ByeBye struct {
// contains filtered or unexported fields
}
func (*ByeBye) Descriptor
deprecated
func (*ByeBye) ProtoMessage ¶
func (*ByeBye) ProtoMessage()
func (*ByeBye) ProtoReflect ¶
func (x *ByeBye) ProtoReflect() protoreflect.Message
type GrpcMessage ¶
type GrpcMessage struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Msg *messagepb.Message `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*GrpcMessage) Descriptor
deprecated
func (*GrpcMessage) Descriptor() ([]byte, []int)
Deprecated: Use GrpcMessage.ProtoReflect.Descriptor instead.
func (*GrpcMessage) GetMsg ¶
func (x *GrpcMessage) GetMsg() *messagepb.Message
func (*GrpcMessage) GetSender ¶
func (x *GrpcMessage) GetSender() string
func (*GrpcMessage) ProtoMessage ¶
func (*GrpcMessage) ProtoMessage()
func (*GrpcMessage) ProtoReflect ¶
func (x *GrpcMessage) ProtoReflect() protoreflect.Message
func (*GrpcMessage) Reset ¶
func (x *GrpcMessage) Reset()
func (*GrpcMessage) String ¶
func (x *GrpcMessage) String() string
type GrpcTransportClient ¶
type GrpcTransportClient interface {
Listen(ctx context.Context, opts ...grpc.CallOption) (GrpcTransport_ListenClient, error)
}
GrpcTransportClient is the client API for GrpcTransport 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 NewGrpcTransportClient ¶
func NewGrpcTransportClient(cc grpc.ClientConnInterface) GrpcTransportClient
type GrpcTransportServer ¶
type GrpcTransportServer interface { Listen(GrpcTransport_ListenServer) error // contains filtered or unexported methods }
GrpcTransportServer is the server API for GrpcTransport service. All implementations must embed UnimplementedGrpcTransportServer for forward compatibility
type GrpcTransport_ListenClient ¶
type GrpcTransport_ListenClient interface { Send(*GrpcMessage) error CloseAndRecv() (*ByeBye, error) grpc.ClientStream }
type GrpcTransport_ListenServer ¶
type GrpcTransport_ListenServer interface { SendAndClose(*ByeBye) error Recv() (*GrpcMessage, error) grpc.ServerStream }
type Transport ¶
type Transport struct { UnimplementedGrpcTransportServer // contains filtered or unexported fields }
Transport represents a networking module that is based on gRPC. Each node's networking module contains one gRPC server, to which other nodes' modules connect. The type of gRPC connection is multi-request-single-response, where each module contains one instance of a gRPC client per node. A message to a node is sent as request to that node's gRPC server.
func NewTransport ¶
NewTransport returns a pointer to a new initialized GrpcTransport networking module. The membership parameter must represent the complete static membership of the system. It maps the node ID of each node in the system to a string representation of its network address with the format "IPAddress:port". The ownId parameter is the ID of the node that will use the returned networking module. The returned GrpcTransport is not yet running (able to receive messages), nor is it connected to any nodes (able to send messages). This needs to be done explicitly by calling the respective Start() and Connect() methods.
func (*Transport) ApplyEvents ¶
func (*Transport) CloseOldConnections ¶
func (gt *Transport) CloseOldConnections(newNodes *trantorpbtypes.Membership)
func (*Transport) Connect ¶
func (gt *Transport) Connect(membership *trantorpbtypes.Membership)
Connect establishes (in parallel) network connections to all nodes according to the membership table. The other nodes' GrpcTransport modules must be running. Only after Connect() returns, sending messages over this GrpcTransport is possible. TODO: Deal with errors, e.g. when the connection times out (make sure the RPC call in connectToNode() has a timeout).
func (*Transport) ImplementsModule ¶
func (gt *Transport) ImplementsModule()
The ImplementsModule method only serves the purpose of indicating that this is a Module and must not be called.
func (*Transport) Listen ¶
func (gt *Transport) Listen(srv GrpcTransport_ListenServer) error
Listen implements the gRPC Listen service (multi-request-single-response). It receives messages from the gRPC client running on the other node and writes them to a channel that the user can access through ReceiveChan(). This function is called by the gRPC system on every new connection from another node's Net module's gRPC client.
func (*Transport) Send ¶
Send sends msg to the node with ID dest. Concurrent calls to Send are not (yet? TODO) supported.
func (*Transport) ServerError ¶
ServerError returns the error returned by the gRPC server's Serve() call. ServerError() must not be called before the GrpcTransport is stopped and its Stop() method has returned.
func (*Transport) Start ¶
Start starts the networking module by initializing and starting the internal gRPC server, listening on the port determined by the membership and own ID. Before ths method is called, no other GrpcTransports can connect to this one.
type UnimplementedGrpcTransportServer ¶
type UnimplementedGrpcTransportServer struct { }
UnimplementedGrpcTransportServer must be embedded to have forward compatible implementations.
func (UnimplementedGrpcTransportServer) Listen ¶
func (UnimplementedGrpcTransportServer) Listen(GrpcTransport_ListenServer) error
type UnsafeGrpcTransportServer ¶
type UnsafeGrpcTransportServer interface {
// contains filtered or unexported methods
}
UnsafeGrpcTransportServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GrpcTransportServer will result in compilation errors.