-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.go
52 lines (44 loc) · 1.17 KB
/
model.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
package clickhousegraphqlgo
import (
"database/sql"
"time"
"github.com/graphql-go/graphql"
)
// Client represents clickhouse DB client connection
type Client struct {
dbClient *sql.DB
apiKey string
accessToken string
schemaSingle *graphql.Schema
schemaList *graphql.Schema
}
// ClientParam represents interface to connect clickhouse and kite ticker stream
type ClientParam struct {
DBSource string
ApiKey string
AccessToken string
}
// tickData represents fields of streaming ticks
type tickData struct {
InstrumentToken int
Timestamp time.Time
LastPrice float64
VolumeTraded int
OI int
}
// tickOutput represents graphql output json fields
type tickOutput struct {
InstrumentToken int `json:"instrument_token"`
LastPrice float64 `json:"lastprice"`
OI int `json:"oi"`
Timestamp time.Time `json:"timestamp"`
VolumeTraded int `json:"volumetraded"`
}
// Result represents graphql output struct
type Result struct {
Output tickOutput `json:"Tick"`
}
// ResultList represents graphql tick list schema output struct
type ResultList struct {
Output []tickOutput `json:"Tick"`
}