mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
305 lines
8.8 KiB
Go
305 lines
8.8 KiB
Go
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
|
// source: proto/chat.proto
|
|
|
|
package chat
|
|
|
|
import (
|
|
fmt "fmt"
|
|
proto "github.com/golang/protobuf/proto"
|
|
math "math"
|
|
)
|
|
|
|
import (
|
|
context "context"
|
|
api "github.com/micro/micro/v3/service/api"
|
|
client "github.com/micro/micro/v3/service/client"
|
|
server "github.com/micro/micro/v3/service/server"
|
|
)
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
var _ = proto.Marshal
|
|
var _ = fmt.Errorf
|
|
var _ = math.Inf
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the proto package it is being compiled against.
|
|
// A compilation error at this line likely means your copy of the
|
|
// proto package needs to be updated.
|
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
var _ api.Endpoint
|
|
var _ context.Context
|
|
var _ client.Option
|
|
var _ server.Option
|
|
|
|
// Api Endpoints for Chat service
|
|
|
|
func NewChatEndpoints() []*api.Endpoint {
|
|
return []*api.Endpoint{}
|
|
}
|
|
|
|
// Client API for Chat service
|
|
|
|
type ChatService interface {
|
|
New(ctx context.Context, in *NewRequest, opts ...client.CallOption) (*NewResponse, error)
|
|
History(ctx context.Context, in *HistoryRequest, opts ...client.CallOption) (*HistoryResponse, error)
|
|
Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error)
|
|
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
|
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
|
|
Join(ctx context.Context, in *JoinRequest, opts ...client.CallOption) (Chat_JoinService, error)
|
|
Invite(ctx context.Context, in *InviteRequest, opts ...client.CallOption) (*InviteResponse, error)
|
|
Leave(ctx context.Context, in *LeaveRequest, opts ...client.CallOption) (*LeaveResponse, error)
|
|
Kick(ctx context.Context, in *KickRequest, opts ...client.CallOption) (*KickResponse, error)
|
|
}
|
|
|
|
type chatService struct {
|
|
c client.Client
|
|
name string
|
|
}
|
|
|
|
func NewChatService(name string, c client.Client) ChatService {
|
|
return &chatService{
|
|
c: c,
|
|
name: name,
|
|
}
|
|
}
|
|
|
|
func (c *chatService) New(ctx context.Context, in *NewRequest, opts ...client.CallOption) (*NewResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.New", in)
|
|
out := new(NewResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) History(ctx context.Context, in *HistoryRequest, opts ...client.CallOption) (*HistoryResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.History", in)
|
|
out := new(HistoryResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.Send", in)
|
|
out := new(SendResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.List", in)
|
|
out := new(ListResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.Delete", in)
|
|
out := new(DeleteResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) Join(ctx context.Context, in *JoinRequest, opts ...client.CallOption) (Chat_JoinService, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.Join", &JoinRequest{})
|
|
stream, err := c.c.Stream(ctx, req, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := stream.Send(in); err != nil {
|
|
return nil, err
|
|
}
|
|
return &chatServiceJoin{stream}, nil
|
|
}
|
|
|
|
type Chat_JoinService interface {
|
|
Context() context.Context
|
|
SendMsg(interface{}) error
|
|
RecvMsg(interface{}) error
|
|
Close() error
|
|
Recv() (*Message, error)
|
|
}
|
|
|
|
type chatServiceJoin struct {
|
|
stream client.Stream
|
|
}
|
|
|
|
func (x *chatServiceJoin) Close() error {
|
|
return x.stream.Close()
|
|
}
|
|
|
|
func (x *chatServiceJoin) Context() context.Context {
|
|
return x.stream.Context()
|
|
}
|
|
|
|
func (x *chatServiceJoin) SendMsg(m interface{}) error {
|
|
return x.stream.Send(m)
|
|
}
|
|
|
|
func (x *chatServiceJoin) RecvMsg(m interface{}) error {
|
|
return x.stream.Recv(m)
|
|
}
|
|
|
|
func (x *chatServiceJoin) Recv() (*Message, error) {
|
|
m := new(Message)
|
|
err := x.stream.Recv(m)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
func (c *chatService) Invite(ctx context.Context, in *InviteRequest, opts ...client.CallOption) (*InviteResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.Invite", in)
|
|
out := new(InviteResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) Leave(ctx context.Context, in *LeaveRequest, opts ...client.CallOption) (*LeaveResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.Leave", in)
|
|
out := new(LeaveResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *chatService) Kick(ctx context.Context, in *KickRequest, opts ...client.CallOption) (*KickResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Chat.Kick", in)
|
|
out := new(KickResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// Server API for Chat service
|
|
|
|
type ChatHandler interface {
|
|
New(context.Context, *NewRequest, *NewResponse) error
|
|
History(context.Context, *HistoryRequest, *HistoryResponse) error
|
|
Send(context.Context, *SendRequest, *SendResponse) error
|
|
List(context.Context, *ListRequest, *ListResponse) error
|
|
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
|
|
Join(context.Context, *JoinRequest, Chat_JoinStream) error
|
|
Invite(context.Context, *InviteRequest, *InviteResponse) error
|
|
Leave(context.Context, *LeaveRequest, *LeaveResponse) error
|
|
Kick(context.Context, *KickRequest, *KickResponse) error
|
|
}
|
|
|
|
func RegisterChatHandler(s server.Server, hdlr ChatHandler, opts ...server.HandlerOption) error {
|
|
type chat interface {
|
|
New(ctx context.Context, in *NewRequest, out *NewResponse) error
|
|
History(ctx context.Context, in *HistoryRequest, out *HistoryResponse) error
|
|
Send(ctx context.Context, in *SendRequest, out *SendResponse) error
|
|
List(ctx context.Context, in *ListRequest, out *ListResponse) error
|
|
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
|
Join(ctx context.Context, stream server.Stream) error
|
|
Invite(ctx context.Context, in *InviteRequest, out *InviteResponse) error
|
|
Leave(ctx context.Context, in *LeaveRequest, out *LeaveResponse) error
|
|
Kick(ctx context.Context, in *KickRequest, out *KickResponse) error
|
|
}
|
|
type Chat struct {
|
|
chat
|
|
}
|
|
h := &chatHandler{hdlr}
|
|
return s.Handle(s.NewHandler(&Chat{h}, opts...))
|
|
}
|
|
|
|
type chatHandler struct {
|
|
ChatHandler
|
|
}
|
|
|
|
func (h *chatHandler) New(ctx context.Context, in *NewRequest, out *NewResponse) error {
|
|
return h.ChatHandler.New(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) History(ctx context.Context, in *HistoryRequest, out *HistoryResponse) error {
|
|
return h.ChatHandler.History(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) Send(ctx context.Context, in *SendRequest, out *SendResponse) error {
|
|
return h.ChatHandler.Send(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
|
return h.ChatHandler.List(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
|
|
return h.ChatHandler.Delete(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) Join(ctx context.Context, stream server.Stream) error {
|
|
m := new(JoinRequest)
|
|
if err := stream.Recv(m); err != nil {
|
|
return err
|
|
}
|
|
return h.ChatHandler.Join(ctx, m, &chatJoinStream{stream})
|
|
}
|
|
|
|
type Chat_JoinStream interface {
|
|
Context() context.Context
|
|
SendMsg(interface{}) error
|
|
RecvMsg(interface{}) error
|
|
Close() error
|
|
Send(*Message) error
|
|
}
|
|
|
|
type chatJoinStream struct {
|
|
stream server.Stream
|
|
}
|
|
|
|
func (x *chatJoinStream) Close() error {
|
|
return x.stream.Close()
|
|
}
|
|
|
|
func (x *chatJoinStream) Context() context.Context {
|
|
return x.stream.Context()
|
|
}
|
|
|
|
func (x *chatJoinStream) SendMsg(m interface{}) error {
|
|
return x.stream.Send(m)
|
|
}
|
|
|
|
func (x *chatJoinStream) RecvMsg(m interface{}) error {
|
|
return x.stream.Recv(m)
|
|
}
|
|
|
|
func (x *chatJoinStream) Send(m *Message) error {
|
|
return x.stream.Send(m)
|
|
}
|
|
|
|
func (h *chatHandler) Invite(ctx context.Context, in *InviteRequest, out *InviteResponse) error {
|
|
return h.ChatHandler.Invite(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) Leave(ctx context.Context, in *LeaveRequest, out *LeaveResponse) error {
|
|
return h.ChatHandler.Leave(ctx, in, out)
|
|
}
|
|
|
|
func (h *chatHandler) Kick(ctx context.Context, in *KickRequest, out *KickResponse) error {
|
|
return h.ChatHandler.Kick(ctx, in, out)
|
|
}
|