mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 22:45:09 +00:00
Refactor Chats Service (#48)
This commit is contained in:
727
chats/proto/chats.pb.go
Normal file
727
chats/proto/chats.pb.go
Normal file
@@ -0,0 +1,727 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.23.0
|
||||
// protoc v3.13.0
|
||||
// source: proto/chats.proto
|
||||
|
||||
package chats
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||
wrappers "github.com/golang/protobuf/ptypes/wrappers"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type Chat struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
UserIds []string `protobuf:"bytes,2,rep,name=user_ids,json=userIds,proto3" json:"user_ids,omitempty"`
|
||||
CreatedAt *timestamp.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Chat) Reset() {
|
||||
*x = Chat{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Chat) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Chat) ProtoMessage() {}
|
||||
|
||||
func (x *Chat) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Chat.ProtoReflect.Descriptor instead.
|
||||
func (*Chat) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Chat) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Chat) GetUserIds() []string {
|
||||
if x != nil {
|
||||
return x.UserIds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Chat) GetCreatedAt() *timestamp.Timestamp {
|
||||
if x != nil {
|
||||
return x.CreatedAt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
AuthorId string `protobuf:"bytes,2,opt,name=author_id,json=authorId,proto3" json:"author_id,omitempty"`
|
||||
ChatId string `protobuf:"bytes,3,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
|
||||
Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
|
||||
SentAt *timestamp.Timestamp `protobuf:"bytes,5,opt,name=sent_at,json=sentAt,proto3" json:"sent_at,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Message) Reset() {
|
||||
*x = Message{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Message) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Message) ProtoMessage() {}
|
||||
|
||||
func (x *Message) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Message.ProtoReflect.Descriptor instead.
|
||||
func (*Message) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Message) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Message) GetAuthorId() string {
|
||||
if x != nil {
|
||||
return x.AuthorId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Message) GetChatId() string {
|
||||
if x != nil {
|
||||
return x.ChatId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Message) GetText() string {
|
||||
if x != nil {
|
||||
return x.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Message) GetSentAt() *timestamp.Timestamp {
|
||||
if x != nil {
|
||||
return x.SentAt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CreateChatRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserIds []string `protobuf:"bytes,1,rep,name=user_ids,json=userIds,proto3" json:"user_ids,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateChatRequest) Reset() {
|
||||
*x = CreateChatRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CreateChatRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateChatRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateChatRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateChatRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateChatRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CreateChatRequest) GetUserIds() []string {
|
||||
if x != nil {
|
||||
return x.UserIds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CreateChatResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Chat *Chat `protobuf:"bytes,1,opt,name=Chat,proto3" json:"Chat,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateChatResponse) Reset() {
|
||||
*x = CreateChatResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CreateChatResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateChatResponse) ProtoMessage() {}
|
||||
|
||||
func (x *CreateChatResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateChatResponse.ProtoReflect.Descriptor instead.
|
||||
func (*CreateChatResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *CreateChatResponse) GetChat() *Chat {
|
||||
if x != nil {
|
||||
return x.Chat
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CreateMessageRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ChatId string `protobuf:"bytes,1,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
|
||||
AuthorId string `protobuf:"bytes,2,opt,name=author_id,json=authorId,proto3" json:"author_id,omitempty"`
|
||||
Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateMessageRequest) Reset() {
|
||||
*x = CreateMessageRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CreateMessageRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateMessageRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateMessageRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateMessageRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateMessageRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *CreateMessageRequest) GetChatId() string {
|
||||
if x != nil {
|
||||
return x.ChatId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateMessageRequest) GetAuthorId() string {
|
||||
if x != nil {
|
||||
return x.AuthorId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateMessageRequest) GetText() string {
|
||||
if x != nil {
|
||||
return x.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateMessageResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Message *Message `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateMessageResponse) Reset() {
|
||||
*x = CreateMessageResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CreateMessageResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateMessageResponse) ProtoMessage() {}
|
||||
|
||||
func (x *CreateMessageResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateMessageResponse.ProtoReflect.Descriptor instead.
|
||||
func (*CreateMessageResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *CreateMessageResponse) GetMessage() *Message {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ListMessagesRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ChatId string `protobuf:"bytes,1,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
|
||||
SentBefore *timestamp.Timestamp `protobuf:"bytes,2,opt,name=sent_before,json=sentBefore,proto3" json:"sent_before,omitempty"`
|
||||
Limit *wrappers.Int32Value `protobuf:"bytes,3,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ListMessagesRequest) Reset() {
|
||||
*x = ListMessagesRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ListMessagesRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListMessagesRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListMessagesRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListMessagesRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListMessagesRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ListMessagesRequest) GetChatId() string {
|
||||
if x != nil {
|
||||
return x.ChatId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListMessagesRequest) GetSentBefore() *timestamp.Timestamp {
|
||||
if x != nil {
|
||||
return x.SentBefore
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ListMessagesRequest) GetLimit() *wrappers.Int32Value {
|
||||
if x != nil {
|
||||
return x.Limit
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ListMessagesResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ListMessagesResponse) Reset() {
|
||||
*x = ListMessagesResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_chats_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ListMessagesResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListMessagesResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListMessagesResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_chats_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListMessagesResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListMessagesResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_chats_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *ListMessagesResponse) GetMessages() []*Message {
|
||||
if x != nil {
|
||||
return x.Messages
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_chats_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_chats_proto_rawDesc = []byte{
|
||||
0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x68, 0x61, 0x74, 0x73, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61,
|
||||
0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x04, 0x43,
|
||||
0x68, 0x61, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x73, 0x18,
|
||||
0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x12, 0x39,
|
||||
0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09,
|
||||
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x98, 0x01, 0x0a, 0x07, 0x4d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x5f,
|
||||
0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
||||
0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x68, 0x61, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||
0x65, 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12,
|
||||
0x33, 0x0a, 0x07, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x06, 0x73, 0x65,
|
||||
0x6e, 0x74, 0x41, 0x74, 0x22, 0x2e, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68,
|
||||
0x61, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x73, 0x65,
|
||||
0x72, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65,
|
||||
0x72, 0x49, 0x64, 0x73, 0x22, 0x35, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68,
|
||||
0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x43, 0x68,
|
||||
0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x73,
|
||||
0x2e, 0x43, 0x68, 0x61, 0x74, 0x52, 0x04, 0x43, 0x68, 0x61, 0x74, 0x22, 0x60, 0x0a, 0x14, 0x43,
|
||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x68, 0x61, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09,
|
||||
0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x08, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78,
|
||||
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x41, 0x0a,
|
||||
0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x73, 0x2e,
|
||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x22, 0x9e, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x74,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x68, 0x61, 0x74, 0x49,
|
||||
0x64, 0x12, 0x3b, 0x0a, 0x0b, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
||||
0x6d, 0x70, 0x52, 0x0a, 0x73, 0x65, 0x6e, 0x74, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x12, 0x31,
|
||||
0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69,
|
||||
0x74, 0x22, 0x42, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x08, 0x6d, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x68,
|
||||
0x61, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x6d, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x05, 0x43, 0x68, 0x61, 0x74, 0x73, 0x12,
|
||||
0x41, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x12, 0x18, 0x2e,
|
||||
0x63, 0x68, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x73, 0x2e,
|
||||
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x12, 0x1b, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61,
|
||||
0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x1c, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47,
|
||||
0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x1a,
|
||||
0x2e, 0x63, 0x68, 0x61, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x63, 0x68, 0x61,
|
||||
0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0d, 0x5a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x3b, 0x63, 0x68, 0x61, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_chats_proto_rawDescOnce sync.Once
|
||||
file_proto_chats_proto_rawDescData = file_proto_chats_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_chats_proto_rawDescGZIP() []byte {
|
||||
file_proto_chats_proto_rawDescOnce.Do(func() {
|
||||
file_proto_chats_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_chats_proto_rawDescData)
|
||||
})
|
||||
return file_proto_chats_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_chats_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_proto_chats_proto_goTypes = []interface{}{
|
||||
(*Chat)(nil), // 0: chats.Chat
|
||||
(*Message)(nil), // 1: chats.Message
|
||||
(*CreateChatRequest)(nil), // 2: chats.CreateChatRequest
|
||||
(*CreateChatResponse)(nil), // 3: chats.CreateChatResponse
|
||||
(*CreateMessageRequest)(nil), // 4: chats.CreateMessageRequest
|
||||
(*CreateMessageResponse)(nil), // 5: chats.CreateMessageResponse
|
||||
(*ListMessagesRequest)(nil), // 6: chats.ListMessagesRequest
|
||||
(*ListMessagesResponse)(nil), // 7: chats.ListMessagesResponse
|
||||
(*timestamp.Timestamp)(nil), // 8: google.protobuf.Timestamp
|
||||
(*wrappers.Int32Value)(nil), // 9: google.protobuf.Int32Value
|
||||
}
|
||||
var file_proto_chats_proto_depIdxs = []int32{
|
||||
8, // 0: chats.Chat.created_at:type_name -> google.protobuf.Timestamp
|
||||
8, // 1: chats.Message.sent_at:type_name -> google.protobuf.Timestamp
|
||||
0, // 2: chats.CreateChatResponse.Chat:type_name -> chats.Chat
|
||||
1, // 3: chats.CreateMessageResponse.message:type_name -> chats.Message
|
||||
8, // 4: chats.ListMessagesRequest.sent_before:type_name -> google.protobuf.Timestamp
|
||||
9, // 5: chats.ListMessagesRequest.limit:type_name -> google.protobuf.Int32Value
|
||||
1, // 6: chats.ListMessagesResponse.messages:type_name -> chats.Message
|
||||
2, // 7: chats.Chats.CreateChat:input_type -> chats.CreateChatRequest
|
||||
4, // 8: chats.Chats.CreateMessage:input_type -> chats.CreateMessageRequest
|
||||
6, // 9: chats.Chats.ListMessages:input_type -> chats.ListMessagesRequest
|
||||
3, // 10: chats.Chats.CreateChat:output_type -> chats.CreateChatResponse
|
||||
5, // 11: chats.Chats.CreateMessage:output_type -> chats.CreateMessageResponse
|
||||
7, // 12: chats.Chats.ListMessages:output_type -> chats.ListMessagesResponse
|
||||
10, // [10:13] is the sub-list for method output_type
|
||||
7, // [7:10] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_chats_proto_init() }
|
||||
func file_proto_chats_proto_init() {
|
||||
if File_proto_chats_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_chats_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Chat); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Message); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CreateChatRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CreateChatResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CreateMessageRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CreateMessageResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ListMessagesRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_chats_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ListMessagesResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_chats_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_chats_proto_goTypes,
|
||||
DependencyIndexes: file_proto_chats_proto_depIdxs,
|
||||
MessageInfos: file_proto_chats_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_chats_proto = out.File
|
||||
file_proto_chats_proto_rawDesc = nil
|
||||
file_proto_chats_proto_goTypes = nil
|
||||
file_proto_chats_proto_depIdxs = nil
|
||||
}
|
||||
139
chats/proto/chats.pb.micro.go
Normal file
139
chats/proto/chats.pb.micro.go
Normal file
@@ -0,0 +1,139 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/chats.proto
|
||||
|
||||
package chats
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
_ "github.com/golang/protobuf/ptypes/wrappers"
|
||||
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 Chats service
|
||||
|
||||
func NewChatsEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for Chats service
|
||||
|
||||
type ChatsService interface {
|
||||
// Create a chat between two or more users, if a chat already exists for these users, the existing
|
||||
// chat will be returned
|
||||
CreateChat(ctx context.Context, in *CreateChatRequest, opts ...client.CallOption) (*CreateChatResponse, error)
|
||||
// Create a message within a chat
|
||||
CreateMessage(ctx context.Context, in *CreateMessageRequest, opts ...client.CallOption) (*CreateMessageResponse, error)
|
||||
// List the messages within a chat in reverse chronological order, using sent_before to
|
||||
// offset as older messages need to be loaded
|
||||
ListMessages(ctx context.Context, in *ListMessagesRequest, opts ...client.CallOption) (*ListMessagesResponse, error)
|
||||
}
|
||||
|
||||
type chatsService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewChatsService(name string, c client.Client) ChatsService {
|
||||
return &chatsService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *chatsService) CreateChat(ctx context.Context, in *CreateChatRequest, opts ...client.CallOption) (*CreateChatResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Chats.CreateChat", in)
|
||||
out := new(CreateChatResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *chatsService) CreateMessage(ctx context.Context, in *CreateMessageRequest, opts ...client.CallOption) (*CreateMessageResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Chats.CreateMessage", in)
|
||||
out := new(CreateMessageResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *chatsService) ListMessages(ctx context.Context, in *ListMessagesRequest, opts ...client.CallOption) (*ListMessagesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Chats.ListMessages", in)
|
||||
out := new(ListMessagesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Chats service
|
||||
|
||||
type ChatsHandler interface {
|
||||
// Create a chat between two or more users, if a chat already exists for these users, the existing
|
||||
// chat will be returned
|
||||
CreateChat(context.Context, *CreateChatRequest, *CreateChatResponse) error
|
||||
// Create a message within a chat
|
||||
CreateMessage(context.Context, *CreateMessageRequest, *CreateMessageResponse) error
|
||||
// List the messages within a chat in reverse chronological order, using sent_before to
|
||||
// offset as older messages need to be loaded
|
||||
ListMessages(context.Context, *ListMessagesRequest, *ListMessagesResponse) error
|
||||
}
|
||||
|
||||
func RegisterChatsHandler(s server.Server, hdlr ChatsHandler, opts ...server.HandlerOption) error {
|
||||
type chats interface {
|
||||
CreateChat(ctx context.Context, in *CreateChatRequest, out *CreateChatResponse) error
|
||||
CreateMessage(ctx context.Context, in *CreateMessageRequest, out *CreateMessageResponse) error
|
||||
ListMessages(ctx context.Context, in *ListMessagesRequest, out *ListMessagesResponse) error
|
||||
}
|
||||
type Chats struct {
|
||||
chats
|
||||
}
|
||||
h := &chatsHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Chats{h}, opts...))
|
||||
}
|
||||
|
||||
type chatsHandler struct {
|
||||
ChatsHandler
|
||||
}
|
||||
|
||||
func (h *chatsHandler) CreateChat(ctx context.Context, in *CreateChatRequest, out *CreateChatResponse) error {
|
||||
return h.ChatsHandler.CreateChat(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *chatsHandler) CreateMessage(ctx context.Context, in *CreateMessageRequest, out *CreateMessageResponse) error {
|
||||
return h.ChatsHandler.CreateMessage(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *chatsHandler) ListMessages(ctx context.Context, in *ListMessagesRequest, out *ListMessagesResponse) error {
|
||||
return h.ChatsHandler.ListMessages(ctx, in, out)
|
||||
}
|
||||
59
chats/proto/chats.proto
Normal file
59
chats/proto/chats.proto
Normal file
@@ -0,0 +1,59 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package chats;
|
||||
option go_package = "proto;chats";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
service Chats {
|
||||
// Create a chat between two or more users, if a chat already exists for these users, the existing
|
||||
// chat will be returned
|
||||
rpc CreateChat(CreateChatRequest) returns (CreateChatResponse);
|
||||
// Create a message within a chat
|
||||
rpc CreateMessage(CreateMessageRequest) returns (CreateMessageResponse);
|
||||
// List the messages within a chat in reverse chronological order, using sent_before to
|
||||
// offset as older messages need to be loaded
|
||||
rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse);
|
||||
}
|
||||
|
||||
message Chat {
|
||||
string id = 1;
|
||||
repeated string user_ids = 2;
|
||||
google.protobuf.Timestamp created_at = 3;
|
||||
}
|
||||
|
||||
message Message {
|
||||
string id = 1;
|
||||
string author_id = 2;
|
||||
string chat_id = 3;
|
||||
string text = 4;
|
||||
google.protobuf.Timestamp sent_at = 5;
|
||||
}
|
||||
|
||||
message CreateChatRequest {
|
||||
repeated string user_ids = 1;
|
||||
}
|
||||
|
||||
message CreateChatResponse {
|
||||
Chat Chat = 1;
|
||||
}
|
||||
|
||||
message CreateMessageRequest {
|
||||
string chat_id = 1;
|
||||
string author_id = 2;
|
||||
string text = 3;
|
||||
}
|
||||
|
||||
message CreateMessageResponse {
|
||||
Message message = 1;
|
||||
}
|
||||
|
||||
message ListMessagesRequest {
|
||||
string chat_id = 1;
|
||||
google.protobuf.Timestamp sent_before = 2;
|
||||
google.protobuf.Int32Value limit = 3;
|
||||
}
|
||||
|
||||
message ListMessagesResponse {
|
||||
repeated Message messages = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user