This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
forked from jaegertracing/jaeger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tchan-baggage.go
105 lines (83 loc) · 3.32 KB
/
tchan-baggage.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
// @generated Code generated by thrift-gen. Do not modify.
// Package baggage is generated code used to make or handle TChannel calls using Thrift.
package baggage
import (
"fmt"
athrift "github.com/apache/thrift/lib/go/thrift"
"github.com/uber/tchannel-go/thrift"
)
// Interfaces for the service and client for the services defined in the IDL.
// TChanBaggageRestrictionManager is the interface that defines the server handler and client interface.
type TChanBaggageRestrictionManager interface {
GetBaggageRestrictions(ctx thrift.Context, serviceName string) ([]*BaggageRestriction, error)
}
// Implementation of a client and service handler.
type tchanBaggageRestrictionManagerClient struct {
thriftService string
client thrift.TChanClient
}
func NewTChanBaggageRestrictionManagerInheritedClient(thriftService string, client thrift.TChanClient) *tchanBaggageRestrictionManagerClient {
return &tchanBaggageRestrictionManagerClient{
thriftService,
client,
}
}
// NewTChanBaggageRestrictionManagerClient creates a client that can be used to make remote calls.
func NewTChanBaggageRestrictionManagerClient(client thrift.TChanClient) TChanBaggageRestrictionManager {
return NewTChanBaggageRestrictionManagerInheritedClient("BaggageRestrictionManager", client)
}
func (c *tchanBaggageRestrictionManagerClient) GetBaggageRestrictions(ctx thrift.Context, serviceName string) ([]*BaggageRestriction, error) {
var resp BaggageRestrictionManagerGetBaggageRestrictionsResult
args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{
ServiceName: serviceName,
}
success, err := c.client.Call(ctx, c.thriftService, "getBaggageRestrictions", &args, &resp)
if err == nil && !success {
switch {
default:
err = fmt.Errorf("received no result or unknown exception for getBaggageRestrictions")
}
}
return resp.GetSuccess(), err
}
type tchanBaggageRestrictionManagerServer struct {
handler TChanBaggageRestrictionManager
}
// NewTChanBaggageRestrictionManagerServer wraps a handler for TChanBaggageRestrictionManager so it can be
// registered with a thrift.Server.
func NewTChanBaggageRestrictionManagerServer(handler TChanBaggageRestrictionManager) thrift.TChanServer {
return &tchanBaggageRestrictionManagerServer{
handler,
}
}
func (s *tchanBaggageRestrictionManagerServer) Service() string {
return "BaggageRestrictionManager"
}
func (s *tchanBaggageRestrictionManagerServer) Methods() []string {
return []string{
"getBaggageRestrictions",
}
}
func (s *tchanBaggageRestrictionManagerServer) Handle(ctx thrift.Context, methodName string, protocol athrift.TProtocol) (bool, athrift.TStruct, error) {
switch methodName {
case "getBaggageRestrictions":
return s.handleGetBaggageRestrictions(ctx, protocol)
default:
return false, nil, fmt.Errorf("method %v not found in service %v", methodName, s.Service())
}
}
func (s *tchanBaggageRestrictionManagerServer) handleGetBaggageRestrictions(ctx thrift.Context, protocol athrift.TProtocol) (bool, athrift.TStruct, error) {
var req BaggageRestrictionManagerGetBaggageRestrictionsArgs
var res BaggageRestrictionManagerGetBaggageRestrictionsResult
if err := req.Read(protocol); err != nil {
return false, nil, err
}
r, err :=
s.handler.GetBaggageRestrictions(ctx, req.ServiceName)
if err != nil {
return false, nil, err
} else {
res.Success = r
}
return err == nil, &res, nil
}