grpc

package
v0.0.0-...-2479739 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_internal_grpc_chat_proto protoreflect.FileDescriptor
View Source
var Hub_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "chat.Hub",
	HandlerType: (*HubServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Chat",
			Handler:       _Hub_Chat_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "internal/grpc/chat.proto",
}

Hub_ServiceDesc is the grpc.ServiceDesc for Hub service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterHubServer

func RegisterHubServer(s grpc.ServiceRegistrar, srv HubServer)

Types

type Connected

type Connected struct {
	Time  *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Users []string               `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"`
	// contains filtered or unexported fields
}

func (*Connected) Descriptor deprecated

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

Deprecated: Use Connected.ProtoReflect.Descriptor instead.

func (*Connected) GetTime

func (x *Connected) GetTime() *timestamppb.Timestamp

func (*Connected) GetUsers

func (x *Connected) GetUsers() []string

func (*Connected) ProtoMessage

func (*Connected) ProtoMessage()

func (*Connected) ProtoReflect

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

func (*Connected) Reset

func (x *Connected) Reset()

func (*Connected) String

func (x *Connected) String() string

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewClientConnection

func NewClientConnection(
	serverAddr string,
	username string,
	logger log.Logger,
) (*Connection, error)

func NewConnection

func NewConnection(
	grpcConn GrpcConnection,
	logger log.Logger,
) *Connection

func (*Connection) Close

func (c *Connection) Close(err error) error

CLose closes connection, if connected. Blocks until disconnected.

func (*Connection) Closed

func (c *Connection) Closed() bool

Closed return chan that is closed when connection is closed.

func (*Connection) Err

func (c *Connection) Err() error

Err returns the error with which the connection closed, or nil.

func (*Connection) ReadEvent

func (c *Connection) ReadEvent() (chat.Event, error)

ReadEvent wiats for next Event. Error when reading fails. Returns error ErrConnectionClosed when connection closed.

func (*Connection) SendEvent

func (c *Connection) SendEvent(e chat.Event) error

SendEvent sends event to the receiver. Returns ErrConnectionClosed when connection closed. Returns error when sending failed.

func (*Connection) Wait

func (c *Connection) Wait() error

Wait waits until connection is closed. Returns error with which the connection was closed (or nil)

func (*Connection) WaitContext

func (c *Connection) WaitContext(ctx context.Context) error

WaitContext waits until connection is closed. Returns error with which the connection was closed (or nil)

type EventEnvelope

type EventEnvelope struct {

	// Types that are assignable to Event:
	//	*EventEnvelope_Connected
	//	*EventEnvelope_UserListUpdate
	//	*EventEnvelope_UserEnter
	//	*EventEnvelope_UserLeave
	//	*EventEnvelope_SendMessage
	//	*EventEnvelope_NewMessage
	Event isEventEnvelope_Event `protobuf_oneof:"event"`
	// contains filtered or unexported fields
}

func (*EventEnvelope) Descriptor deprecated

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

Deprecated: Use EventEnvelope.ProtoReflect.Descriptor instead.

func (*EventEnvelope) GetConnected

func (x *EventEnvelope) GetConnected() *Connected

func (*EventEnvelope) GetEvent

func (m *EventEnvelope) GetEvent() isEventEnvelope_Event

func (*EventEnvelope) GetNewMessage

func (x *EventEnvelope) GetNewMessage() *NewMessage

func (*EventEnvelope) GetSendMessage

func (x *EventEnvelope) GetSendMessage() *SendMessage

func (*EventEnvelope) GetUserEnter

func (x *EventEnvelope) GetUserEnter() *UserEnter

func (*EventEnvelope) GetUserLeave

func (x *EventEnvelope) GetUserLeave() *UserLeave

func (*EventEnvelope) GetUserListUpdate

func (x *EventEnvelope) GetUserListUpdate() *UserListUpdate

func (*EventEnvelope) ProtoMessage

func (*EventEnvelope) ProtoMessage()

func (*EventEnvelope) ProtoReflect

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

func (*EventEnvelope) Reset

func (x *EventEnvelope) Reset()

func (*EventEnvelope) String

func (x *EventEnvelope) String() string

type EventEnvelope_Connected

type EventEnvelope_Connected struct {
	Connected *Connected `protobuf:"bytes,2,opt,name=connected,proto3,oneof"`
}

type EventEnvelope_NewMessage

type EventEnvelope_NewMessage struct {
	NewMessage *NewMessage `protobuf:"bytes,7,opt,name=newMessage,proto3,oneof"`
}

type EventEnvelope_SendMessage

type EventEnvelope_SendMessage struct {
	SendMessage *SendMessage `protobuf:"bytes,6,opt,name=sendMessage,proto3,oneof"`
}

type EventEnvelope_UserEnter

type EventEnvelope_UserEnter struct {
	UserEnter *UserEnter `protobuf:"bytes,4,opt,name=userEnter,proto3,oneof"`
}

type EventEnvelope_UserLeave

type EventEnvelope_UserLeave struct {
	UserLeave *UserLeave `protobuf:"bytes,5,opt,name=userLeave,proto3,oneof"`
}

type EventEnvelope_UserListUpdate

type EventEnvelope_UserListUpdate struct {
	UserListUpdate *UserListUpdate `protobuf:"bytes,3,opt,name=userListUpdate,proto3,oneof"`
}

type GrpcConnection

type GrpcConnection interface {
	Send(*EventEnvelope) error
	Recv() (*EventEnvelope, error)
}

type HubClient

type HubClient interface {
	Chat(ctx context.Context, opts ...grpc.CallOption) (Hub_ChatClient, error)
}

HubClient is the client API for Hub 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 NewHubClient

func NewHubClient(cc grpc.ClientConnInterface) HubClient

type HubServer

type HubServer interface {
	Chat(Hub_ChatServer) error
	// contains filtered or unexported methods
}

HubServer is the server API for Hub service. All implementations must embed UnimplementedHubServer for forward compatibility

type HubService

type HubService struct {
	// contains filtered or unexported fields
}

func (*HubService) Chat

func (h *HubService) Chat(s Hub_ChatServer) error

type Hub_ChatClient

type Hub_ChatClient interface {
	Send(*EventEnvelope) error
	Recv() (*EventEnvelope, error)
	grpc.ClientStream
}

type Hub_ChatServer

type Hub_ChatServer interface {
	Send(*EventEnvelope) error
	Recv() (*EventEnvelope, error)
	grpc.ServerStream
}

type NewMessage

type NewMessage struct {
	Time    *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Sender  string                 `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"`
	Message string                 `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*NewMessage) Descriptor deprecated

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

Deprecated: Use NewMessage.ProtoReflect.Descriptor instead.

func (*NewMessage) GetMessage

func (x *NewMessage) GetMessage() string

func (*NewMessage) GetSender

func (x *NewMessage) GetSender() string

func (*NewMessage) GetTime

func (x *NewMessage) GetTime() *timestamppb.Timestamp

func (*NewMessage) ProtoMessage

func (*NewMessage) ProtoMessage()

func (*NewMessage) ProtoReflect

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

func (*NewMessage) Reset

func (x *NewMessage) Reset()

func (*NewMessage) String

func (x *NewMessage) String() string

type SendMessage

type SendMessage struct {
	Time    *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Message string                 `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*SendMessage) Descriptor deprecated

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

Deprecated: Use SendMessage.ProtoReflect.Descriptor instead.

func (*SendMessage) GetMessage

func (x *SendMessage) GetMessage() string

func (*SendMessage) GetTime

func (x *SendMessage) GetTime() *timestamppb.Timestamp

func (*SendMessage) ProtoMessage

func (*SendMessage) ProtoMessage()

func (*SendMessage) ProtoReflect

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

func (*SendMessage) Reset

func (x *SendMessage) Reset()

func (*SendMessage) String

func (x *SendMessage) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(logger log.Logger) *Server

func (*Server) Start

func (s *Server) Start(addr string) error

func (*Server) Stop

func (s *Server) Stop() error

type UnimplementedHubServer

type UnimplementedHubServer struct {
}

UnimplementedHubServer must be embedded to have forward compatible implementations.

func (UnimplementedHubServer) Chat

type UnsafeHubServer

type UnsafeHubServer interface {
	// contains filtered or unexported methods
}

UnsafeHubServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to HubServer will result in compilation errors.

type UserEnter

type UserEnter struct {
	Time *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Name string                 `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*UserEnter) Descriptor deprecated

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

Deprecated: Use UserEnter.ProtoReflect.Descriptor instead.

func (*UserEnter) GetName

func (x *UserEnter) GetName() string

func (*UserEnter) GetTime

func (x *UserEnter) GetTime() *timestamppb.Timestamp

func (*UserEnter) ProtoMessage

func (*UserEnter) ProtoMessage()

func (*UserEnter) ProtoReflect

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

func (*UserEnter) Reset

func (x *UserEnter) Reset()

func (*UserEnter) String

func (x *UserEnter) String() string

type UserLeave

type UserLeave struct {
	Time *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Name string                 `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*UserLeave) Descriptor deprecated

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

Deprecated: Use UserLeave.ProtoReflect.Descriptor instead.

func (*UserLeave) GetName

func (x *UserLeave) GetName() string

func (*UserLeave) GetTime

func (x *UserLeave) GetTime() *timestamppb.Timestamp

func (*UserLeave) ProtoMessage

func (*UserLeave) ProtoMessage()

func (*UserLeave) ProtoReflect

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

func (*UserLeave) Reset

func (x *UserLeave) Reset()

func (*UserLeave) String

func (x *UserLeave) String() string

type UserListUpdate

type UserListUpdate struct {
	Time  *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Users []string               `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"`
	// contains filtered or unexported fields
}

func (*UserListUpdate) Descriptor deprecated

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

Deprecated: Use UserListUpdate.ProtoReflect.Descriptor instead.

func (*UserListUpdate) GetTime

func (x *UserListUpdate) GetTime() *timestamppb.Timestamp

func (*UserListUpdate) GetUsers

func (x *UserListUpdate) GetUsers() []string

func (*UserListUpdate) ProtoMessage

func (*UserListUpdate) ProtoMessage()

func (*UserListUpdate) ProtoReflect

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

func (*UserListUpdate) Reset

func (x *UserListUpdate) Reset()

func (*UserListUpdate) String

func (x *UserListUpdate) String() string

Jump to

Keyboard shortcuts

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