grpc

package
v0.0.0-...-9727c61 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 27 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 []byte `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
	// Types that are assignable to Type:
	//	*GrpcMessage_PbMsg
	//	*GrpcMessage_RawMsg
	Type isGrpcMessage_Type `protobuf_oneof:"type"`
	// contains filtered or unexported fields
}

func (*GrpcMessage) Descriptor deprecated

func (*GrpcMessage) Descriptor() ([]byte, []int)

Deprecated: Use GrpcMessage.ProtoReflect.Descriptor instead.

func (*GrpcMessage) GetPbMsg

func (x *GrpcMessage) GetPbMsg() *messagepb.Message

func (*GrpcMessage) GetRawMsg

func (x *GrpcMessage) GetRawMsg() *RawMessage

func (*GrpcMessage) GetSender

func (x *GrpcMessage) GetSender() []byte

func (*GrpcMessage) GetType

func (m *GrpcMessage) GetType() isGrpcMessage_Type

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 GrpcMessage_PbMsg

type GrpcMessage_PbMsg struct {
	PbMsg *messagepb.Message `protobuf:"bytes,2,opt,name=pb_msg,json=pbMsg,proto3,oneof"`
}

type GrpcMessage_RawMsg

type GrpcMessage_RawMsg struct {
	RawMsg *RawMessage `protobuf:"bytes,3,opt,name=raw_msg,json=rawMsg,proto3,oneof"`
}

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 Params

type Params struct {
	ConnectionBufferSize int           `json:",string"`
	ReconnectionPeriod   time.Duration `json:",string"`
	MinComplainPeriod    time.Duration `json:",string"`
}

func DefaultParams

func DefaultParams() Params

type RawMessage

type RawMessage struct {
	DestModule string `protobuf:"bytes,1,opt,name=dest_module,json=destModule,proto3" json:"dest_module,omitempty"`
	Data       []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*RawMessage) Descriptor deprecated

func (*RawMessage) Descriptor() ([]byte, []int)

Deprecated: Use RawMessage.ProtoReflect.Descriptor instead.

func (*RawMessage) GetData

func (x *RawMessage) GetData() []byte

func (*RawMessage) GetDestModule

func (x *RawMessage) GetDestModule() string

func (*RawMessage) ProtoMessage

func (*RawMessage) ProtoMessage()

func (*RawMessage) ProtoReflect

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

func (*RawMessage) Reset

func (x *RawMessage) Reset()

func (*RawMessage) String

func (x *RawMessage) String() string

type Transport

type Transport struct {
	UnimplementedGrpcTransportServer
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(
	params Params,
	ownID stdtypes.NodeID,
	ownAddr string,
	logger logging.Logger,
	stats mirnet.Stats,
) (*Transport, error)

func (*Transport) ApplyEvents

func (tr *Transport) ApplyEvents(
	ctx context.Context,
	eventList *stdtypes.EventList,
) error

func (*Transport) ApplyPbEvent

func (tr *Transport) ApplyPbEvent(ctx context.Context, evt *eventpb.Event) error

func (*Transport) CloseOldConnections

func (tr *Transport) CloseOldConnections(newMembership *trantorpbtypes.Membership)

func (*Transport) Connect

func (tr *Transport) Connect(membership *trantorpbtypes.Membership)

func (*Transport) EventsOut

func (tr *Transport) EventsOut() <-chan *stdtypes.EventList

func (*Transport) ImplementsModule

func (tr *Transport) ImplementsModule()

func (*Transport) Listen

func (tr *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 (tr *Transport) Send(dest stdtypes.NodeID, msg *messagepb.Message) error

Send sends a protobuf type message msg to the node with ID dest. Concurrent calls to Send are not (yet? TODO) supported. This is just a wrapper around SendPbMessage. TODO: generalize interface to take a stdtypes.Message instead.

func (*Transport) SendPbMessage

func (tr *Transport) SendPbMessage(destNode stdtypes.NodeID, msg *messagepb.Message) error

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

func (*Transport) SendRawMessage

func (tr *Transport) SendRawMessage(destNode stdtypes.NodeID, destModule stdtypes.ModuleID, message stdtypes.Message) error

func (*Transport) ServerError

func (tr *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 (tr *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 (tr *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 (tr *Transport) WaitFor(n int) error

type TransportMessage

type TransportMessage struct {
	Sender  []byte
	Payload []byte
}

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