forked from goadesign/examples
/
types.go
42 lines (37 loc) · 1.19 KB
/
types.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
// Code generated by goa v3.13.2, DO NOT EDIT.
//
// calc gRPC server types
//
// Command:
// $ goa gen github.com/ikawaha/examples/error/design
package server
import (
calc "github.com/ikawaha/examples/error/gen/calc"
calcpb "github.com/ikawaha/examples/error/gen/grpc/calc/pb"
)
// NewDividePayload builds the payload of the "divide" endpoint of the "calc"
// service from the gRPC request type.
func NewDividePayload(message *calcpb.DivideRequest) *calc.DividePayload {
v := &calc.DividePayload{
Dividend: int(message.Dividend),
Divisor: int(message.Divisor),
}
return v
}
// NewProtoDivideResponse builds the gRPC response type from the result of the
// "divide" endpoint of the "calc" service.
func NewProtoDivideResponse(result *calc.DivideResult) *calcpb.DivideResponse {
message := &calcpb.DivideResponse{
Quotient: int32(result.Quotient),
Reminder: int32(result.Reminder),
}
return message
}
// NewDivideDivByZeroError builds the gRPC error response type from the error
// of the "divide" endpoint of the "calc" service.
func NewDivideDivByZeroError(er *calc.DivByZero) *calcpb.DivideDivByZeroError {
message := &calcpb.DivideDivByZeroError{
Message_: er.Message,
}
return message
}