-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
83 lines (71 loc) · 2.61 KB
/
server.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
package server
import (
"context"
"github.com/golang/protobuf/ptypes/duration"
"github.com/golang/protobuf/ptypes/empty"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/ncrypthic/graphql-grpc-edge/example/grpc/sample"
"github.com/opentracing/opentracing-go"
"google.golang.org/protobuf/types/known/emptypb"
)
type HelloServer struct {
sample.UnimplementedHelloServiceServer
sample.UnimplementedHelloTestServiceServer
}
func (h *HelloServer) Greeting(ctx context.Context, req *sample.HelloRequest) (*sample.HelloResponse, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "Greeting")
defer span.Finish()
return &sample.HelloResponse{
Data: &sample.Hello{
Name: req.Name,
},
}, nil
}
func (h *HelloServer) SetGreeting(ctx context.Context, req *sample.Hello) (*sample.HelloResponse, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return &sample.HelloResponse{
Data: &sample.Hello{
Name: req.Name,
Type: req.Type,
Messages: req.Messages,
CreatedAt: req.CreatedAt,
},
}, nil
}
func (h *HelloServer) HelloQuery(ctx context.Context, req *sample.Test) (*sample.Test, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return req, nil
}
func (h *HelloServer) GetGreeting(ctx context.Context, req *sample.Hello) (*empty.Empty, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return &emptypb.Empty{}, nil
}
func (h *HelloServer) SetDuration(ctx context.Context, req *duration.Duration) (*duration.Duration, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return req, nil
}
func (h *HelloServer) SetTimestamp(ctx context.Context, req *timestamp.Timestamp) (*timestamp.Timestamp, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return req, nil
}
func (h *HelloServer) SetInt32Value(ctx context.Context, req *wrappers.Int32Value) (*wrappers.Int32Value, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return req, nil
}
func (h *HelloServer) SetBoolValue(ctx context.Context, req *wrappers.BoolValue) (*wrappers.BoolValue, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return req, nil
}
func (h *HelloServer) SetStringValue(ctx context.Context, req *wrappers.StringValue) (*wrappers.StringValue, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "SetGreeting")
defer span.Finish()
return req, nil
}