chore: initial chat proto contracts (topics, messages, subscribe, acknowledge)
This commit is contained in:
commit
c833ff147a
24
README.md
Normal file
24
README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# l-ai-chat-proto
|
||||||
|
|
||||||
|
Protobuf-контракты Live Chat (`l-ai-chat`). Репозиторий хранит и `.proto`, и сгенерированный Go-код (как остальные proto-модули проекта).
|
||||||
|
|
||||||
|
## Содержимое
|
||||||
|
|
||||||
|
- `chat.proto` — единый контракт `ChatService` (topics, post/get/history, subscribe, acknowledge) + `Message`/`Topic` + enums `AuthorType`/`MessageSource`.
|
||||||
|
- `chat.pb.go`, `chat_grpc.pb.go` — сгенерированный код, закоммичен.
|
||||||
|
|
||||||
|
## Регенерация
|
||||||
|
|
||||||
|
Нужны `protoc` + `protoc-gen-go` + `protoc-gen-go-grpc` в PATH:
|
||||||
|
|
||||||
|
```bat
|
||||||
|
generate_proto.bat
|
||||||
|
```
|
||||||
|
|
||||||
|
Сгенерированный код коммитится в этот репозиторий; сервисы подключают его как git submodule (см. `l-ai-chat/proto/l-ai-chat-proto`).
|
||||||
|
|
||||||
|
## Соглашения
|
||||||
|
|
||||||
|
- `package chat`, `option go_package = "git.be.kaien.ru/l-ai/l-ai-chat-proto/proto"`.
|
||||||
|
- Enum-значения префиксованы (`AUTHOR_TYPE_*`, `MESSAGE_SOURCE_*`) — избегаем C++-scoping коллизий.
|
||||||
|
- История пагинируется по `sequence` (`before_sequence`/`after_sequence`), offset-пагинации нет.
|
||||||
1215
chat.pb.go
Normal file
1215
chat.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
157
chat.proto
Normal file
157
chat.proto
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package chat;
|
||||||
|
|
||||||
|
option go_package = "git.be.kaien.ru/l-ai/l-ai-chat-proto/proto";
|
||||||
|
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
|
// ChatService is the canonical API of the l-ai-chat Live Chat service.
|
||||||
|
// Chat Service is the single source of truth for messages; clients (Web UI,
|
||||||
|
// Telegram bot, agents) send and read messages through it.
|
||||||
|
service ChatService {
|
||||||
|
// ListTopics returns all topics in stable (creation) order.
|
||||||
|
rpc ListTopics(ListTopicsRequest) returns (ListTopicsResponse);
|
||||||
|
|
||||||
|
// GetTopic returns one topic by id or slug.
|
||||||
|
rpc GetTopic(GetTopicRequest) returns (Topic);
|
||||||
|
|
||||||
|
// CreateTopic creates a new topic. Slug must be unique.
|
||||||
|
rpc CreateTopic(CreateTopicRequest) returns (Topic);
|
||||||
|
|
||||||
|
// PostMessage appends a message to a topic. Repeated calls with the same
|
||||||
|
// (author_id, idempotency_key) must not create a second message; the
|
||||||
|
// original message is returned with duplicated=true instead.
|
||||||
|
rpc PostMessage(PostMessageRequest) returns (PostMessageResponse);
|
||||||
|
|
||||||
|
// GetMessage returns a single message by id.
|
||||||
|
rpc GetMessage(GetMessageRequest) returns (Message);
|
||||||
|
|
||||||
|
// History returns messages of a topic, paginated by sequence (no offset
|
||||||
|
// pagination). Use before_sequence for newest-first backward paging or
|
||||||
|
// after_sequence for oldest-first forward paging; at most one may be set.
|
||||||
|
rpc History(HistoryRequest) returns (HistoryResponse);
|
||||||
|
|
||||||
|
// Subscribe streams new messages of a topic to a consumer. The consumer is
|
||||||
|
// expected to Acknowledge the messages it processed (at-least-once).
|
||||||
|
// NOTE: stream delivery is implemented in a later stage.
|
||||||
|
rpc Subscribe(SubscribeRequest) returns (stream Message);
|
||||||
|
|
||||||
|
// Acknowledge advances the durable delivery cursor of a consumer in a
|
||||||
|
// topic. Cursors are monotonic: the stored value never moves backwards.
|
||||||
|
rpc Acknowledge(AcknowledgeRequest) returns (AcknowledgeResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorType is the kind of identity a message author has. HUMAN covers
|
||||||
|
// internal users (the same author_id across Web and Telegram), AGENT covers
|
||||||
|
// l-ai agents, SYSTEM covers service-internal messages, INTEGRATION covers
|
||||||
|
// bridge/external systems.
|
||||||
|
enum AuthorType {
|
||||||
|
AUTHOR_TYPE_UNSPECIFIED = 0;
|
||||||
|
AUTHOR_TYPE_HUMAN = 1;
|
||||||
|
AUTHOR_TYPE_AGENT = 2;
|
||||||
|
AUTHOR_TYPE_SYSTEM = 3;
|
||||||
|
AUTHOR_TYPE_INTEGRATION = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MessageSource is the channel through which a message entered the system.
|
||||||
|
enum MessageSource {
|
||||||
|
MESSAGE_SOURCE_UNSPECIFIED = 0;
|
||||||
|
MESSAGE_SOURCE_WEB = 1;
|
||||||
|
MESSAGE_SOURCE_TELEGRAM = 2;
|
||||||
|
MESSAGE_SOURCE_AGENT = 3;
|
||||||
|
MESSAGE_SOURCE_SYSTEM = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Topic {
|
||||||
|
string id = 1; // UUID
|
||||||
|
string slug = 2; // stable, unique, e.g. "security"
|
||||||
|
string display_name = 3; // e.g. "Security"
|
||||||
|
google.protobuf.Timestamp created_at = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Message {
|
||||||
|
string id = 1; // UUID, canonical message id
|
||||||
|
int64 sequence = 2; // server-assigned monotonic sequence (ordering + durable cursor)
|
||||||
|
string topic_id = 3; // UUID
|
||||||
|
string author_id = 4; // stable identity of the author (UUID)
|
||||||
|
AuthorType author_type = 5;
|
||||||
|
MessageSource source = 6;
|
||||||
|
string content = 7;
|
||||||
|
optional string reply_to_message_id = 8; // parent message when this is a reply
|
||||||
|
string root_message_id = 9; // root of the reply chain (== id for non-replies)
|
||||||
|
int32 reply_depth = 10; // 0 for non-replies, parent depth + 1 for replies; hard max 20
|
||||||
|
google.protobuf.Timestamp created_at = 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ListTopicsRequest {}
|
||||||
|
|
||||||
|
message ListTopicsResponse {
|
||||||
|
repeated Topic topics = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTopicRequest {
|
||||||
|
oneof selector {
|
||||||
|
string id = 1;
|
||||||
|
string slug = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateTopicRequest {
|
||||||
|
string slug = 1;
|
||||||
|
string display_name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PostMessageRequest {
|
||||||
|
string topic_id = 1;
|
||||||
|
string author_id = 2;
|
||||||
|
AuthorType author_type = 3;
|
||||||
|
MessageSource source = 4;
|
||||||
|
string content = 5;
|
||||||
|
optional string reply_to_message_id = 6;
|
||||||
|
// Idempotency key: retrying PostMessage with the same author_id and key
|
||||||
|
// returns the original message instead of creating a duplicate.
|
||||||
|
string idempotency_key = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PostMessageResponse {
|
||||||
|
Message message = 1;
|
||||||
|
bool duplicated = 2; // true when an idempotent replay returned an existing message
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetMessageRequest {
|
||||||
|
string message_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message HistoryRequest {
|
||||||
|
string topic_id = 1;
|
||||||
|
// Backward paging: return messages with sequence < before_sequence,
|
||||||
|
// newest first. Mutually exclusive with after_sequence.
|
||||||
|
int64 before_sequence = 2;
|
||||||
|
// Forward paging: return messages with sequence > after_sequence,
|
||||||
|
// oldest first. Mutually exclusive with before_sequence.
|
||||||
|
int64 after_sequence = 3;
|
||||||
|
// Maximum number of messages to return (server may cap it).
|
||||||
|
int32 limit = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message HistoryResponse {
|
||||||
|
repeated Message messages = 1;
|
||||||
|
// true when more messages exist in the requested direction.
|
||||||
|
bool has_more = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SubscribeRequest {
|
||||||
|
string consumer_id = 1; // stable identity of the consumer/agent
|
||||||
|
string topic_id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AcknowledgeRequest {
|
||||||
|
string consumer_id = 1;
|
||||||
|
string topic_id = 2;
|
||||||
|
int64 last_ack_sequence = 3; // highest sequence processed by the consumer
|
||||||
|
}
|
||||||
|
|
||||||
|
message AcknowledgeResponse {
|
||||||
|
int64 last_ack_sequence = 1; // the cursor as stored (never lower than before)
|
||||||
|
}
|
||||||
429
chat_grpc.pb.go
Normal file
429
chat_grpc.pb.go
Normal file
@ -0,0 +1,429 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.6.2
|
||||||
|
// - protoc v7.35.1
|
||||||
|
// source: chat.proto
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.64.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
|
const (
|
||||||
|
ChatService_ListTopics_FullMethodName = "/chat.ChatService/ListTopics"
|
||||||
|
ChatService_GetTopic_FullMethodName = "/chat.ChatService/GetTopic"
|
||||||
|
ChatService_CreateTopic_FullMethodName = "/chat.ChatService/CreateTopic"
|
||||||
|
ChatService_PostMessage_FullMethodName = "/chat.ChatService/PostMessage"
|
||||||
|
ChatService_GetMessage_FullMethodName = "/chat.ChatService/GetMessage"
|
||||||
|
ChatService_History_FullMethodName = "/chat.ChatService/History"
|
||||||
|
ChatService_Subscribe_FullMethodName = "/chat.ChatService/Subscribe"
|
||||||
|
ChatService_Acknowledge_FullMethodName = "/chat.ChatService/Acknowledge"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChatServiceClient is the client API for ChatService 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.
|
||||||
|
//
|
||||||
|
// ChatService is the canonical API of the l-ai-chat Live Chat service.
|
||||||
|
// Chat Service is the single source of truth for messages; clients (Web UI,
|
||||||
|
// Telegram bot, agents) send and read messages through it.
|
||||||
|
type ChatServiceClient interface {
|
||||||
|
// ListTopics returns all topics in stable (creation) order.
|
||||||
|
ListTopics(ctx context.Context, in *ListTopicsRequest, opts ...grpc.CallOption) (*ListTopicsResponse, error)
|
||||||
|
// GetTopic returns one topic by id or slug.
|
||||||
|
GetTopic(ctx context.Context, in *GetTopicRequest, opts ...grpc.CallOption) (*Topic, error)
|
||||||
|
// CreateTopic creates a new topic. Slug must be unique.
|
||||||
|
CreateTopic(ctx context.Context, in *CreateTopicRequest, opts ...grpc.CallOption) (*Topic, error)
|
||||||
|
// PostMessage appends a message to a topic. Repeated calls with the same
|
||||||
|
// (author_id, idempotency_key) must not create a second message; the
|
||||||
|
// original message is returned with duplicated=true instead.
|
||||||
|
PostMessage(ctx context.Context, in *PostMessageRequest, opts ...grpc.CallOption) (*PostMessageResponse, error)
|
||||||
|
// GetMessage returns a single message by id.
|
||||||
|
GetMessage(ctx context.Context, in *GetMessageRequest, opts ...grpc.CallOption) (*Message, error)
|
||||||
|
// History returns messages of a topic, paginated by sequence (no offset
|
||||||
|
// pagination). Use before_sequence for newest-first backward paging or
|
||||||
|
// after_sequence for oldest-first forward paging; at most one may be set.
|
||||||
|
History(ctx context.Context, in *HistoryRequest, opts ...grpc.CallOption) (*HistoryResponse, error)
|
||||||
|
// Subscribe streams new messages of a topic to a consumer. The consumer is
|
||||||
|
// expected to Acknowledge the messages it processed (at-least-once).
|
||||||
|
// NOTE: stream delivery is implemented in a later stage.
|
||||||
|
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Message], error)
|
||||||
|
// Acknowledge advances the durable delivery cursor of a consumer in a
|
||||||
|
// topic. Cursors are monotonic: the stored value never moves backwards.
|
||||||
|
Acknowledge(ctx context.Context, in *AcknowledgeRequest, opts ...grpc.CallOption) (*AcknowledgeResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type chatServiceClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewChatServiceClient(cc grpc.ClientConnInterface) ChatServiceClient {
|
||||||
|
return &chatServiceClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) ListTopics(ctx context.Context, in *ListTopicsRequest, opts ...grpc.CallOption) (*ListTopicsResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(ListTopicsResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_ListTopics_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) GetTopic(ctx context.Context, in *GetTopicRequest, opts ...grpc.CallOption) (*Topic, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(Topic)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_GetTopic_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) CreateTopic(ctx context.Context, in *CreateTopicRequest, opts ...grpc.CallOption) (*Topic, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(Topic)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_CreateTopic_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) PostMessage(ctx context.Context, in *PostMessageRequest, opts ...grpc.CallOption) (*PostMessageResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(PostMessageResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_PostMessage_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) GetMessage(ctx context.Context, in *GetMessageRequest, opts ...grpc.CallOption) (*Message, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(Message)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_GetMessage_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) History(ctx context.Context, in *HistoryRequest, opts ...grpc.CallOption) (*HistoryResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(HistoryResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_History_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chatServiceClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Message], error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
stream, err := c.cc.NewStream(ctx, &ChatService_ServiceDesc.Streams[0], ChatService_Subscribe_FullMethodName, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
x := &grpc.GenericClientStream[SubscribeRequest, Message]{ClientStream: stream}
|
||||||
|
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := x.ClientStream.CloseSend(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||||
|
type ChatService_SubscribeClient = grpc.ServerStreamingClient[Message]
|
||||||
|
|
||||||
|
func (c *chatServiceClient) Acknowledge(ctx context.Context, in *AcknowledgeRequest, opts ...grpc.CallOption) (*AcknowledgeResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(AcknowledgeResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ChatService_Acknowledge_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatServiceServer is the server API for ChatService service.
|
||||||
|
// All implementations must embed UnimplementedChatServiceServer
|
||||||
|
// for forward compatibility.
|
||||||
|
//
|
||||||
|
// ChatService is the canonical API of the l-ai-chat Live Chat service.
|
||||||
|
// Chat Service is the single source of truth for messages; clients (Web UI,
|
||||||
|
// Telegram bot, agents) send and read messages through it.
|
||||||
|
type ChatServiceServer interface {
|
||||||
|
// ListTopics returns all topics in stable (creation) order.
|
||||||
|
ListTopics(context.Context, *ListTopicsRequest) (*ListTopicsResponse, error)
|
||||||
|
// GetTopic returns one topic by id or slug.
|
||||||
|
GetTopic(context.Context, *GetTopicRequest) (*Topic, error)
|
||||||
|
// CreateTopic creates a new topic. Slug must be unique.
|
||||||
|
CreateTopic(context.Context, *CreateTopicRequest) (*Topic, error)
|
||||||
|
// PostMessage appends a message to a topic. Repeated calls with the same
|
||||||
|
// (author_id, idempotency_key) must not create a second message; the
|
||||||
|
// original message is returned with duplicated=true instead.
|
||||||
|
PostMessage(context.Context, *PostMessageRequest) (*PostMessageResponse, error)
|
||||||
|
// GetMessage returns a single message by id.
|
||||||
|
GetMessage(context.Context, *GetMessageRequest) (*Message, error)
|
||||||
|
// History returns messages of a topic, paginated by sequence (no offset
|
||||||
|
// pagination). Use before_sequence for newest-first backward paging or
|
||||||
|
// after_sequence for oldest-first forward paging; at most one may be set.
|
||||||
|
History(context.Context, *HistoryRequest) (*HistoryResponse, error)
|
||||||
|
// Subscribe streams new messages of a topic to a consumer. The consumer is
|
||||||
|
// expected to Acknowledge the messages it processed (at-least-once).
|
||||||
|
// NOTE: stream delivery is implemented in a later stage.
|
||||||
|
Subscribe(*SubscribeRequest, grpc.ServerStreamingServer[Message]) error
|
||||||
|
// Acknowledge advances the durable delivery cursor of a consumer in a
|
||||||
|
// topic. Cursors are monotonic: the stored value never moves backwards.
|
||||||
|
Acknowledge(context.Context, *AcknowledgeRequest) (*AcknowledgeResponse, error)
|
||||||
|
mustEmbedUnimplementedChatServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedChatServiceServer must be embedded to have
|
||||||
|
// forward compatible implementations.
|
||||||
|
//
|
||||||
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||||
|
// pointer dereference when methods are called.
|
||||||
|
type UnimplementedChatServiceServer struct{}
|
||||||
|
|
||||||
|
func (UnimplementedChatServiceServer) ListTopics(context.Context, *ListTopicsRequest) (*ListTopicsResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method ListTopics not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) GetTopic(context.Context, *GetTopicRequest) (*Topic, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method GetTopic not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) CreateTopic(context.Context, *CreateTopicRequest) (*Topic, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method CreateTopic not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) PostMessage(context.Context, *PostMessageRequest) (*PostMessageResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method PostMessage not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) GetMessage(context.Context, *GetMessageRequest) (*Message, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method GetMessage not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) History(context.Context, *HistoryRequest) (*HistoryResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method History not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) Subscribe(*SubscribeRequest, grpc.ServerStreamingServer[Message]) error {
|
||||||
|
return status.Error(codes.Unimplemented, "method Subscribe not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) Acknowledge(context.Context, *AcknowledgeRequest) (*AcknowledgeResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method Acknowledge not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedChatServiceServer) mustEmbedUnimplementedChatServiceServer() {}
|
||||||
|
func (UnimplementedChatServiceServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
// UnsafeChatServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to ChatServiceServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeChatServiceServer interface {
|
||||||
|
mustEmbedUnimplementedChatServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterChatServiceServer(s grpc.ServiceRegistrar, srv ChatServiceServer) {
|
||||||
|
// If the following call panics, it indicates UnimplementedChatServiceServer was
|
||||||
|
// embedded by pointer and is nil. This will cause panics if an
|
||||||
|
// unimplemented method is ever invoked, so we test this at initialization
|
||||||
|
// time to prevent it from happening at runtime later due to I/O.
|
||||||
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||||
|
t.testEmbeddedByValue()
|
||||||
|
}
|
||||||
|
s.RegisterService(&ChatService_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_ListTopics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(ListTopicsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).ListTopics(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_ListTopics_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).ListTopics(ctx, req.(*ListTopicsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_GetTopic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetTopicRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).GetTopic(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_GetTopic_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).GetTopic(ctx, req.(*GetTopicRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_CreateTopic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateTopicRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).CreateTopic(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_CreateTopic_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).CreateTopic(ctx, req.(*CreateTopicRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_PostMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(PostMessageRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).PostMessage(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_PostMessage_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).PostMessage(ctx, req.(*PostMessageRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_GetMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetMessageRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).GetMessage(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_GetMessage_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).GetMessage(ctx, req.(*GetMessageRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_History_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(HistoryRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).History(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_History_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).History(ctx, req.(*HistoryRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ChatService_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||||
|
m := new(SubscribeRequest)
|
||||||
|
if err := stream.RecvMsg(m); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return srv.(ChatServiceServer).Subscribe(m, &grpc.GenericServerStream[SubscribeRequest, Message]{ServerStream: stream})
|
||||||
|
}
|
||||||
|
|
||||||
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||||
|
type ChatService_SubscribeServer = grpc.ServerStreamingServer[Message]
|
||||||
|
|
||||||
|
func _ChatService_Acknowledge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(AcknowledgeRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ChatServiceServer).Acknowledge(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ChatService_Acknowledge_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ChatServiceServer).Acknowledge(ctx, req.(*AcknowledgeRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatService_ServiceDesc is the grpc.ServiceDesc for ChatService service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var ChatService_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "chat.ChatService",
|
||||||
|
HandlerType: (*ChatServiceServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "ListTopics",
|
||||||
|
Handler: _ChatService_ListTopics_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetTopic",
|
||||||
|
Handler: _ChatService_GetTopic_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "CreateTopic",
|
||||||
|
Handler: _ChatService_CreateTopic_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "PostMessage",
|
||||||
|
Handler: _ChatService_PostMessage_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetMessage",
|
||||||
|
Handler: _ChatService_GetMessage_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "History",
|
||||||
|
Handler: _ChatService_History_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Acknowledge",
|
||||||
|
Handler: _ChatService_Acknowledge_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{
|
||||||
|
{
|
||||||
|
StreamName: "Subscribe",
|
||||||
|
Handler: _ChatService_Subscribe_Handler,
|
||||||
|
ServerStreams: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Metadata: "chat.proto",
|
||||||
|
}
|
||||||
6
generate_proto.bat
Normal file
6
generate_proto.bat
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
echo Generating gRPC code from chat.proto...
|
||||||
|
protoc --go_out=. --go_opt=paths=source_relative ^
|
||||||
|
--go-grpc_out=. --go-grpc_opt=paths=source_relative ^
|
||||||
|
chat.proto
|
||||||
|
echo Done!
|
||||||
Loading…
Reference in New Issue
Block a user