-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
68 lines (54 loc) · 2.04 KB
/
status.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
//go:generate go run tools/withoutctx.go
package redash
import (
"context"
"github.com/winebarrel/redash-go/v2/internal/util"
)
type Status struct {
DashboardsCount int `json:"dashboards_count"`
DatabaseMetrics StatusDatabaseMetrics `json:"database_metrics"`
Manager StatusManager `json:"manager"`
QueriesCount int `json:"queries_count"`
QueryResultsCount int `json:"query_results_count"`
RedisUsedMemory int `json:"redis_used_memory"`
RedisUsedMemoryHuman string `json:"redis_used_memory_human"`
UnusedQueryResultsCount int `json:"unused_query_results_count"`
Version string `json:"version"`
WidgetsCount int `json:"widgets_count"`
Workers []any `json:"workers"`
}
type StatusDatabaseMetrics struct {
Metrics [][]any `json:"metrics"`
}
type StatusManager struct {
LastRefreshAt string `json:"last_refresh_at"`
OutdatedQueriesCount string `json:"outdated_queries_count"`
QueryIds string `json:"query_ids"`
Queues StatusManagerQueues `json:"queues"`
}
type StatusManagerQueues struct {
Celery StatusManagerQueuesCelery `json:"celery"`
Queries StatusManagerQueuesQueries `json:"queries"`
ScheduledQueries StatusManagerQueuesScheduledQueries `json:"scheduled_queries"`
}
type StatusManagerQueuesCelery struct {
Size int `json:"size"`
}
type StatusManagerQueuesQueries struct {
Size int `json:"size"`
}
type StatusManagerQueuesScheduledQueries struct {
Size int `json:"size"`
}
func (client *Client) GetStatus(ctx context.Context) (*Status, error) {
res, close, err := client.Get(ctx, "status.json", nil)
defer close()
if err != nil {
return nil, err
}
status := &Status{}
if err := util.UnmarshalBody(res, &status); err != nil {
return nil, err
}
return status, nil
}