-
Notifications
You must be signed in to change notification settings - Fork 175
/
cells-registry_grpc.enhanced.pb.go
176 lines (163 loc) · 5.8 KB
/
cells-registry_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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.1.0
// - protoc (unknown)
// source: cells-registry.proto
package registry
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 (
enhancedRegistryServers = make(map[string]RegistryEnhancedServer)
enhancedRegistryServersLock = sync.RWMutex{}
)
type NamedRegistryServer interface {
RegistryServer
Name() string
}
type RegistryEnhancedServer map[string]NamedRegistryServer
func (m RegistryEnhancedServer) Start(ctx context.Context, r *Item) (*EmptyResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method Start should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.Start(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method Start not implemented")
}
func (m RegistryEnhancedServer) Stop(ctx context.Context, r *Item) (*EmptyResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method Stop should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.Stop(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method Stop not implemented")
}
func (m RegistryEnhancedServer) Get(ctx context.Context, r *GetRequest) (*GetResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method Get should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.Get(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
}
func (m RegistryEnhancedServer) Register(ctx context.Context, r *Item) (*EmptyResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method Register should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.Register(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (m RegistryEnhancedServer) Deregister(ctx context.Context, r *Item) (*EmptyResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method Deregister should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.Deregister(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method Deregister not implemented")
}
func (m RegistryEnhancedServer) List(ctx context.Context, r *ListRequest) (*ListResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method List should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.List(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (m RegistryEnhancedServer) Watch(r *WatchRequest, s Registry_WatchServer) error {
md, ok := metadata.FromIncomingContext(s.Context())
if !ok || len(md.Get("targetname")) == 0 {
return status.Errorf(codes.FailedPrecondition, "method Watch should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.Watch(r, s)
}
}
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
}
func (m RegistryEnhancedServer) NewLocker(s Registry_NewLockerServer) error {
md, ok := metadata.FromIncomingContext(s.Context())
if !ok || len(md.Get("targetname")) == 0 {
return status.Errorf(codes.FailedPrecondition, "method NewLocker should have a context")
}
enhancedRegistryServersLock.RLock()
defer enhancedRegistryServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.NewLocker(s)
}
}
return status.Errorf(codes.Unimplemented, "method NewLocker not implemented")
}
func (m RegistryEnhancedServer) mustEmbedUnimplementedRegistryServer() {}
func RegisterRegistryEnhancedServer(s grpc.ServiceRegistrar, srv NamedRegistryServer) {
enhancedRegistryServersLock.Lock()
defer enhancedRegistryServersLock.Unlock()
addr := fmt.Sprintf("%p", s)
m, ok := enhancedRegistryServers[addr]
if !ok {
m = RegistryEnhancedServer{}
enhancedRegistryServers[addr] = m
RegisterRegistryServer(s, m)
}
m[srv.Name()] = srv
}
func DeregisterRegistryEnhancedServer(s grpc.ServiceRegistrar, name string) {
enhancedRegistryServersLock.Lock()
defer enhancedRegistryServersLock.Unlock()
addr := fmt.Sprintf("%p", s)
m, ok := enhancedRegistryServers[addr]
if !ok {
return
}
delete(m, name)
}