-
Notifications
You must be signed in to change notification settings - Fork 4
/
util.gunk
60 lines (52 loc) · 1.19 KB
/
util.gunk
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
// +gunk proto.Package("gunk.example.v1")
// +gunk java.Package("gunk.example.v1")
// +gunk java.MultipleFiles(true)
package v1
import (
"github.com/gunk/opt/field"
"github.com/gunk/opt/file/java"
"github.com/gunk/opt/http"
"github.com/gunk/opt/proto"
)
// Util is the util service.
type Util interface {
// CheckStatus returns the server health status.
//
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/status",
// }
CheckStatus() CheckStatusResponse
// Echo echoes a message.
//
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/echo",
// }
// +gunk http.Match{
// Method: "POST",
// Path: "/v1/echo",
// Body: "*",
// }
Echo(Message) Message
}
// Status is a server health status.
type Status int
// Status values.
const (
Unknown Status = iota
Error
OK
)
// Message is a echo message.
type Message struct {
// Msg holds a message.
Msg string `pb:"1" json:"msg"`
Code int `pb:"2" json:"code"`
}
// CheckStatusResponse is the server health status response.
type CheckStatusResponse struct {
Status Status `pb:"1" json:"status"`
// +gunk field.Deprecated(true)
OldField int `pb:"2" json:"old_field"`
}