-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
105 lines (88 loc) · 3.18 KB
/
api.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package dbinfo
import (
"context"
"database/sql"
"github.com/boltdb/bolt"
"github.com/gocql/gocql"
"github.com/globalsign/mgo"
"github.com/gomodule/redigo/redis"
)
type Store interface {
GetVersion(context.Context) (*DBVersion, error)
GetActiveClient(context.Context) (*DBActiveClient, error)
GetHealth(context.Context) (*DBHealth, error)
}
type Conn struct {
Session *mgo.Session
DB *sql.DB
Con redis.Conn
CQLSession *gocql.Session
BoltDB *bolt.DB
}
type DBVersion struct {
Version string `json:"version,omitempty"`
}
type DBActiveClient struct {
ActiveClient int `json:"active_client,omitempty"`
}
type DBHealth struct {
PsqlHealth PsqlHealth `json:"psql_health,omitempty"`
RedisHealth RedisHealth `json:"redis_health,omitempty"`
MongoHealth MongoHealth `json:"mongo_health,omitempty"`
CassandraHealth CassandraHealth `json:"cassandra_health,omitempty"`
BoltHealth BoltHealth `json:"bolt_health,omitempty"`
SQLiteHealth SQLiteHealth `json:"sqlite_health,omitempty"`
}
type PsqlHealth struct {
DBInformation DBInformation `json:"db_information,omitempty"`
TableInformation []TableInformation `json:"table_information,omitempty"`
}
type DBInformation struct {
DBName string `json:"db_name,omitempty"`
DBSize string `json:"db_size,omitempty"`
}
type TableInformation struct {
SchemaName string `json:"schema_name,omitempty"`
TableName string `json:"table_name,omitempty"`
TableSize string `json:"table_size,omitempty"`
IndexSize string `json:"index_size,omitempty"`
}
type RedisHealth struct {
AvailableKey int `json:"available_key,omitempty"`
MemoryUsage string `json:"memory_usage,omitempty"`
ExpiredKeys string `json:"expired_key,omitempty"`
EvictedKeys string `json:"evicted_key,omitempty"`
SlowlogCount int `json:"slow_count,omitempty"`
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
}
type MemoryStats struct {
PeakAllocated int64 `json:"peak_allocated,omitempty"`
TotalAllowed int64 `json:"total_allowed,omitempty"`
StartupAllocated int64 `json:"startup_allocated,omitempty"`
PeakPercentage int64 `json:"peak_percentage,omitempty"`
Fragmentation int64 `json:"fragmentation,omitempty"`
}
type MongoHealth struct {
DBName string `json:"dbname,omitempty"`
AvailableCollection int `json:"available_collection,omitempty"`
StorageSize float64 `json:"storage_size,omitempty"`
Indexes int `json:"indexes,omitempty"`
DataSize float64 `json:"data_size,omitempty"`
}
type CassandraHealth struct {
ID string `json:"id,omitempty"`
GossipActive string `json:"gossip,omitempty"`
ThriftActive string `json:"thrift,omitempty"`
NativeTransport string `json:"native,omitempty"`
Load string `json:"load,omitempty"`
GenerationNo string `json:"gen_number,omitempty"`
Uptime string `json:"uptime,omitempty"`
}
type BoltHealth struct {
NumberOfBucket int `json:"number_of_bucket,omitempty"`
NumberOfKey int `json:"number_of_key,omitempty"`
}
type SQLiteHealth struct {
PragmaPageSize int `json:"page_size,omitempty"`
PragmaPageCount int `json:"page_count,omitempty"`
}