-
Notifications
You must be signed in to change notification settings - Fork 180
/
cells-chat_grpc.enhanced.pb.go
146 lines (135 loc) · 5.04 KB
/
cells-chat_grpc.enhanced.pb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.1.0
// - protoc v3.18.1
// source: cells-chat.proto
package chat
import (
context "context"
fmt "fmt"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
metadata "google.golang.org/grpc/metadata"
status "google.golang.org/grpc/status"
sync "sync"
)
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
var (
enhancedChatServiceServers = make(map[string]ChatServiceEnhancedServer)
enhancedChatServiceServersLock = sync.RWMutex{}
)
type NamedChatServiceServer interface {
ChatServiceServer
Name() string
}
type ChatServiceEnhancedServer map[string]NamedChatServiceServer
func (m ChatServiceEnhancedServer) PutRoom(ctx context.Context, r *PutRoomRequest) (*PutRoomResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method PutRoom should have a context")
}
enhancedChatServiceServersLock.RLock()
defer enhancedChatServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.PutRoom(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method PutRoom not implemented")
}
func (m ChatServiceEnhancedServer) DeleteRoom(ctx context.Context, r *DeleteRoomRequest) (*DeleteRoomResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method DeleteRoom should have a context")
}
enhancedChatServiceServersLock.RLock()
defer enhancedChatServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.DeleteRoom(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method DeleteRoom not implemented")
}
func (m ChatServiceEnhancedServer) ListRooms(r *ListRoomsRequest, s ChatService_ListRoomsServer) error {
md, ok := metadata.FromIncomingContext(s.Context())
if !ok || len(md.Get("targetname")) == 0 {
return status.Errorf(codes.FailedPrecondition, "method ListRooms should have a context")
}
enhancedChatServiceServersLock.RLock()
defer enhancedChatServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.ListRooms(r, s)
}
}
return status.Errorf(codes.Unimplemented, "method ListRooms not implemented")
}
func (m ChatServiceEnhancedServer) ListMessages(r *ListMessagesRequest, s ChatService_ListMessagesServer) error {
md, ok := metadata.FromIncomingContext(s.Context())
if !ok || len(md.Get("targetname")) == 0 {
return status.Errorf(codes.FailedPrecondition, "method ListMessages should have a context")
}
enhancedChatServiceServersLock.RLock()
defer enhancedChatServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.ListMessages(r, s)
}
}
return status.Errorf(codes.Unimplemented, "method ListMessages not implemented")
}
func (m ChatServiceEnhancedServer) PostMessage(ctx context.Context, r *PostMessageRequest) (*PostMessageResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method PostMessage should have a context")
}
enhancedChatServiceServersLock.RLock()
defer enhancedChatServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.PostMessage(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method PostMessage not implemented")
}
func (m ChatServiceEnhancedServer) DeleteMessage(ctx context.Context, r *DeleteMessageRequest) (*DeleteMessageResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method DeleteMessage should have a context")
}
enhancedChatServiceServersLock.RLock()
defer enhancedChatServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.DeleteMessage(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method DeleteMessage not implemented")
}
func (m ChatServiceEnhancedServer) mustEmbedUnimplementedChatServiceServer() {}
func RegisterChatServiceEnhancedServer(s grpc.ServiceRegistrar, srv NamedChatServiceServer) {
enhancedChatServiceServersLock.Lock()
defer enhancedChatServiceServersLock.Unlock()
addr := fmt.Sprintf("%p", s)
m, ok := enhancedChatServiceServers[addr]
if !ok {
m = ChatServiceEnhancedServer{}
enhancedChatServiceServers[addr] = m
RegisterChatServiceServer(s, m)
}
m[srv.Name()] = srv
}
func DeregisterChatServiceEnhancedServer(s grpc.ServiceRegistrar, name string) {
enhancedChatServiceServersLock.Lock()
defer enhancedChatServiceServersLock.Unlock()
addr := fmt.Sprintf("%p", s)
m, ok := enhancedChatServiceServers[addr]
if !ok {
return
}
delete(m, name)
}