grpc

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_net_grpc_grpctransport_proto protoreflect.FileDescriptor
View Source
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) Descriptor() ([]byte, []int)

Deprecated: Use ByeBye.ProtoReflect.Descriptor instead.

func (*ByeBye) ProtoMessage

func (*ByeBye) ProtoMessage()

func (*ByeBye) ProtoReflect

func (x *ByeBye) ProtoReflect() protoreflect.Message

func (*ByeBye) Reset

func (x *ByeBye) Reset()

func (*ByeBye) String

func (x *ByeBye) String() string

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.

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

func NewTransport(id t.NodeID, addrStr string, l logging.Logger) (*Transport, error)

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 (gt *Transport) ApplyEvents(
	ctx context.Context,
	eventList *events.EventList,
) error

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) EventsOut

func (gt *Transport) EventsOut() <-chan *events.EventList

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

func (gt *Transport) Send(dest t.NodeID, msg *messagepb.Message) error

Send sends msg to the node with ID dest. Concurrent calls to Send are not (yet? TODO) supported.

func (*Transport) ServerError

func (gt *Transport) ServerError() error

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

func (gt *Transport) Start() error

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.

func (*Transport) Stop

func (gt *Transport) Stop()

Stop closes all open connections to other nodes and stops the own gRPC server (preventing further incoming connections). After Stop() returns, the error returned by the gRPC server's Serve() call can be obtained through the ServerError() method.

func (*Transport) WaitFor

func (gt *Transport) WaitFor(_ int) error

type UnimplementedGrpcTransportServer

type UnimplementedGrpcTransportServer struct {
}

UnimplementedGrpcTransportServer must be embedded to have forward compatible implementations.

func (UnimplementedGrpcTransportServer) Listen

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL