@@ -5,11 +5,31 @@ import (
5
5
"net/url"
6
6
7
7
"github.com/dyweb/gommon/errors"
8
+ "github.com/libtsdb/libtsdb-go/database"
9
+ "github.com/libtsdb/libtsdb-go/database/kairosdb"
8
10
"github.com/libtsdb/libtsdb-go/database/kairosdb/config"
9
11
"github.com/libtsdb/libtsdb-go/protocol"
10
12
)
11
13
12
- func NewKairosDBHTTPClient (cfg config.KairosdbClientConfig ) (* protocol.HTTPClient , error ) {
14
+ type KairosDBHTTPClient struct {
15
+ * protocol.HTTPClient
16
+ meta database.Meta
17
+ }
18
+
19
+ func (c * KairosDBHTTPClient ) Meta () database.Meta {
20
+ return c .meta
21
+ }
22
+
23
+ type KairosDBTCPCLient struct {
24
+ * protocol.TCPClient
25
+ meta database.Meta
26
+ }
27
+
28
+ func (c * KairosDBTCPCLient ) Meta () database.Meta {
29
+ return c .meta
30
+ }
31
+
32
+ func NewKairosDBHTTPClient (cfg config.KairosdbClientConfig ) (* KairosDBHTTPClient , error ) {
13
33
u , err := url .Parse (cfg .Addr )
14
34
if err != nil {
15
35
return nil , errors .Wrap (err , "can't parse server address" )
@@ -19,9 +39,13 @@ func NewKairosDBHTTPClient(cfg config.KairosdbClientConfig) (*protocol.HTTPClien
19
39
return nil , errors .Wrap (err , "can't create base query" )
20
40
}
21
41
c := protocol .NewHTTPClient (NewKairosDBJSONEncoder (), baseReq )
22
- return c , nil
42
+ return & KairosDBHTTPClient { HTTPClient : c , meta : kairosdb . Meta ()} , nil
23
43
}
24
44
25
- func NewKairosDBTCPClient (cfg config.KairosdbClientConfig ) (* protocol.TCPClient , error ) {
26
- return protocol .NewTCPClient (NewKaiorsDBTelnetEncoder (), cfg .TelnetAddr , cfg .Timeout )
45
+ func NewKairosDBTCPClient (cfg config.KairosdbClientConfig ) (* KairosDBTCPCLient , error ) {
46
+ p , err := protocol .NewTCPClient (NewKaiorsDBTelnetEncoder (), cfg .TelnetAddr , cfg .Timeout )
47
+ if err != nil {
48
+ return nil , err
49
+ }
50
+ return & KairosDBTCPCLient {TCPClient : p , meta : kairosdb .Meta ()}, nil
27
51
}
0 commit comments