-
Notifications
You must be signed in to change notification settings - Fork 180
/
cells-mailer_grpc.enhanced.pb.go
86 lines (79 loc) · 2.81 KB
/
cells-mailer_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
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.1.0
// - protoc v3.18.1
// source: cells-mailer.proto
package mailer
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 (
enhancedMailerServiceServers = make(map[string]MailerServiceEnhancedServer)
enhancedMailerServiceServersLock = sync.RWMutex{}
)
type NamedMailerServiceServer interface {
MailerServiceServer
Name() string
}
type MailerServiceEnhancedServer map[string]NamedMailerServiceServer
func (m MailerServiceEnhancedServer) SendMail(ctx context.Context, r *SendMailRequest) (*SendMailResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method SendMail should have a context")
}
enhancedMailerServiceServersLock.RLock()
defer enhancedMailerServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.SendMail(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method SendMail not implemented")
}
func (m MailerServiceEnhancedServer) ConsumeQueue(ctx context.Context, r *ConsumeQueueRequest) (*ConsumeQueueResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok || len(md.Get("targetname")) == 0 {
return nil, status.Errorf(codes.FailedPrecondition, "method ConsumeQueue should have a context")
}
enhancedMailerServiceServersLock.RLock()
defer enhancedMailerServiceServersLock.RUnlock()
for _, mm := range m {
if mm.Name() == md.Get("targetname")[0] {
return mm.ConsumeQueue(ctx, r)
}
}
return nil, status.Errorf(codes.Unimplemented, "method ConsumeQueue not implemented")
}
func (m MailerServiceEnhancedServer) mustEmbedUnimplementedMailerServiceServer() {}
func RegisterMailerServiceEnhancedServer(s grpc.ServiceRegistrar, srv NamedMailerServiceServer) {
enhancedMailerServiceServersLock.Lock()
defer enhancedMailerServiceServersLock.Unlock()
addr := fmt.Sprintf("%p", s)
m, ok := enhancedMailerServiceServers[addr]
if !ok {
m = MailerServiceEnhancedServer{}
enhancedMailerServiceServers[addr] = m
RegisterMailerServiceServer(s, m)
}
m[srv.Name()] = srv
}
func DeregisterMailerServiceEnhancedServer(s grpc.ServiceRegistrar, name string) {
enhancedMailerServiceServersLock.Lock()
defer enhancedMailerServiceServersLock.Unlock()
addr := fmt.Sprintf("%p", s)
m, ok := enhancedMailerServiceServers[addr]
if !ok {
return
}
delete(m, name)
}