Support app version on api.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
ca3ec3293d
commit
b744208a29
2
Makefile
2
Makefile
|
@ -35,7 +35,7 @@ update:
|
|||
glide update
|
||||
|
||||
build_static:
|
||||
go build -ldflags="${EXTLDFLAGS}-s -w -X main.Version=${VERSION}" -o bin/gorush gorush.go
|
||||
go build -ldflags='${EXTLDFLAGS}-s -w -X main.Version=${VERSION}' -o bin/gorush gorush.go
|
||||
|
||||
build: clean
|
||||
sh script/build.sh $(VERSION)
|
||||
|
|
|
@ -260,6 +260,7 @@ Show success or failure counts information of notification.
|
|||
|
||||
```json
|
||||
{
|
||||
"version": "v1.6.2",
|
||||
"queue_max": 8192,
|
||||
"queue_usage": 0,
|
||||
"total_count": 77,
|
||||
|
|
|
@ -102,8 +102,16 @@ func TestAPIStatusAppHandler(t *testing.T) {
|
|||
|
||||
r := gofight.New()
|
||||
|
||||
appVersion := "v1.0.0"
|
||||
SetVersion(appVersion)
|
||||
|
||||
r.GET("/api/stat/app").
|
||||
Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
|
||||
data := []byte(r.Body.String())
|
||||
|
||||
value, _ := jsonparser.GetString(data, "version")
|
||||
|
||||
assert.Equal(t, appVersion, value)
|
||||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ var Stats = stats.New()
|
|||
|
||||
// StatusApp is app status structure
|
||||
type StatusApp struct {
|
||||
Version string `json:"version"`
|
||||
QueueMax int `json:"queue_max"`
|
||||
QueueUsage int `json:"queue_usage"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
|
@ -66,6 +67,7 @@ func InitAppStatus() error {
|
|||
func appStatusHandler(c *gin.Context) {
|
||||
result := StatusApp{}
|
||||
|
||||
result.Version = GetVersion()
|
||||
result.QueueMax = cap(QueueNotification)
|
||||
result.QueueUsage = len(QueueNotification)
|
||||
result.TotalCount = StatStorage.GetTotalCount()
|
||||
|
|
Loading…
Reference in New Issue