Refactor long readRedisInfoReplyFields() function
[ric-plt/sdlgo.git] / internal / sdlgoredis / dbinfo.go
1 /*
2    Copyright (c) 2021 AT&T Intellectual Property.
3    Copyright (c) 2018-2021 Nokia.
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 */
17
18 /*
19  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
20  * platform project (RICP).
21  */
22
23 package sdlgoredis
24
25 //DbInfo struct is a holder for DB information, which is received from
26 //sdlgoredis 'info' call's output.
27 type DbInfo struct {
28         Fields DbInfoFields
29 }
30
31 //DbInfoFields struct is a holder for fields, which are read from sdlgoredis
32 //'info' call's output.
33 type DbInfoFields struct {
34         PrimaryRole         bool
35         ConnectedReplicaCnt uint32
36         Server              ServerInfoFields
37         Clients             ClientsInfoFields
38         Memory              MeroryInfoFields
39         Stats               StatsInfoFields
40         Cpu                 CpuInfoFields
41         Commandstats        CommandstatsInfoFields
42         Keyspace            KeyspaceInfoFields
43 }
44
45 type ServerInfoFields struct {
46         UptimeInDays uint32
47 }
48
49 type ClientsInfoFields struct {
50         ConnectedClients            uint32
51         ClientRecentMaxInputBuffer  uint32
52         ClientRecentMaxOutputBuffer uint32
53 }
54
55 type MeroryInfoFields struct {
56         UsedMemory            uint64
57         UsedMemoryHuman       string
58         UsedMemoryRss         uint64
59         UsedMemoryRssHuman    string
60         UsedMemoryPeak        uint64
61         UsedMemoryPeakHuman   string
62         UsedMemoryPeakPerc    string
63         MemFragmentationRatio float32
64         MemFragmentationBytes uint32
65 }
66
67 type StatsInfoFields struct {
68         TotalConnectionsReceived uint32
69         TotalCommandsProcessed   uint32
70         SyncFull                 uint32
71         SyncPartialOk            uint32
72         SyncPartialErr           uint32
73         PubsubChannels           uint32
74 }
75
76 type CpuInfoFields struct {
77         UsedCpuSys  float64
78         UsedCpuUser float64
79 }
80
81 type CommandstatsValues struct {
82         Calls       uint32
83         Usec        uint32
84         UsecPerCall float32
85 }
86
87 type CommandstatsInfoFields struct {
88         CmdstatReplconf  CommandstatsValues
89         CmdstatKeys      CommandstatsValues
90         CmdstatRole      CommandstatsValues
91         CmdstatConfig    CommandstatsValues
92         CmdstatPsync     CommandstatsValues
93         CmdstatMset      CommandstatsValues
94         CmdstatPublish   CommandstatsValues
95         CmdstatInfo      CommandstatsValues
96         CmdstatPing      CommandstatsValues
97         CmdstatClient    CommandstatsValues
98         CmdstatCommand   CommandstatsValues
99         CmdstatSubscribe CommandstatsValues
100         CmdstatMonitor   CommandstatsValues
101         CmdstatSlaveof   CommandstatsValues
102 }
103
104 type KeyspaceValues struct {
105         Keys    uint32
106         Expires uint32
107         AvgTtl  uint32
108 }
109
110 type KeyspaceInfoFields struct {
111         Db KeyspaceValues
112 }
113
114 type ConfigInfo map[string]string