forked from devimteam/microgen
/
server.microgen.go
91 lines (80 loc) · 3.57 KB
/
server.microgen.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
// Code generated by microgen 0.9.0. DO NOT EDIT.
package transport
import (
"context"
usersvc "github.com/devimteam/microgen/examples/usersvc/pkg/usersvc"
endpoint "github.com/go-kit/kit/endpoint"
opentracing "github.com/go-kit/kit/tracing/opentracing"
opentracinggo "github.com/opentracing/opentracing-go"
)
func Endpoints(svc usersvc.UserService) EndpointsSet {
return EndpointsSet{
CreateCommentEndpoint: CreateCommentEndpoint(svc),
CreateUserEndpoint: CreateUserEndpoint(svc),
FindUsersEndpoint: FindUsersEndpoint(svc),
GetCommentEndpoint: GetCommentEndpoint(svc),
GetUserCommentsEndpoint: GetUserCommentsEndpoint(svc),
GetUserEndpoint: GetUserEndpoint(svc),
UpdateUserEndpoint: UpdateUserEndpoint(svc),
}
}
// TraceServerEndpoints is used for tracing endpoints on server side.
func TraceServerEndpoints(endpoints EndpointsSet, tracer opentracinggo.Tracer) EndpointsSet {
return EndpointsSet{
CreateCommentEndpoint: opentracing.TraceServer(tracer, "CreateComment")(endpoints.CreateCommentEndpoint),
CreateUserEndpoint: opentracing.TraceServer(tracer, "CreateUser")(endpoints.CreateUserEndpoint),
FindUsersEndpoint: opentracing.TraceServer(tracer, "FindUsers")(endpoints.FindUsersEndpoint),
GetCommentEndpoint: opentracing.TraceServer(tracer, "GetComment")(endpoints.GetCommentEndpoint),
GetUserCommentsEndpoint: opentracing.TraceServer(tracer, "GetUserComments")(endpoints.GetUserCommentsEndpoint),
GetUserEndpoint: opentracing.TraceServer(tracer, "GetUser")(endpoints.GetUserEndpoint),
UpdateUserEndpoint: opentracing.TraceServer(tracer, "UpdateUser")(endpoints.UpdateUserEndpoint),
}
}
func CreateUserEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*CreateUserRequest)
res0, res1 := svc.CreateUser(arg0, req.User)
return &CreateUserResponse{Id: res0}, res1
}
}
func UpdateUserEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*UpdateUserRequest)
res0 := svc.UpdateUser(arg0, req.User)
return &UpdateUserResponse{}, res0
}
}
func GetUserEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*GetUserRequest)
res0, res1 := svc.GetUser(arg0, req.Id)
return &GetUserResponse{User: res0}, res1
}
}
func FindUsersEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
res0, res1 := svc.FindUsers(arg0)
return &FindUsersResponse{Results: res0}, res1
}
}
func CreateCommentEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*CreateCommentRequest)
res0, res1 := svc.CreateComment(arg0, req.Comment)
return &CreateCommentResponse{Id: res0}, res1
}
}
func GetCommentEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*GetCommentRequest)
res0, res1 := svc.GetComment(arg0, req.Id)
return &GetCommentResponse{Comment: res0}, res1
}
}
func GetUserCommentsEndpoint(svc usersvc.UserService) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*GetUserCommentsRequest)
res0, res1 := svc.GetUserComments(arg0, req.UserId)
return &GetUserCommentsResponse{List: res0}, res1
}
}