-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdbtasks_push.go
73 lines (61 loc) · 1.4 KB
/
dbtasks_push.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
package goshare
import "strings"
/*
PushKeyVal pushes a given set of Key-Val.
*/
func PushKeyVal(key string, val string) bool {
return tsds.PushKeyVal(key, val)
}
/*
PushKeyValNS pushes a given Namespace-Key and its value.
*/
func PushKeyValNS(key string, val string) bool {
return tsds.PushNS(key, val)
}
/*
PushKeyValNowTSDS pushes a key namespace-d with current time.
*/
func PushKeyValNowTSDS(key string, val string) bool {
return tsds.PushNowTSDS(key, val)
}
/*
PushKeyValTSDS pushes a key namespace-d with goltime.Timestamp.
*/
func PushKeyValTSDS(packet Packet) bool {
status := true
for _key, _val := range packet.HashMap {
_val = strings.Replace(_val, "\n", " ", -1)
status = status && tsds.PushTSDS(_key, _val, packet.TimeDot)
}
return status
}
/*
PushFuncByKeyType returns func handle according to KeyType.
*/
func PushFuncByKeyType(keyType string) FunkAxnParamKeyVal {
switch keyType {
case "now":
return PushKeyValNowTSDS
case "ns":
return PushKeyValNS
default:
return PushKeyVal
}
}
/*
PushFromPacket handles push task based on provided Packet.
*/
func PushFromPacket(packet Packet) bool {
status := true
switch packet.KeyType {
case "tsds":
PushKeyValTSDS(packet)
default:
axnFunk := PushFuncByKeyType(packet.KeyType)
for _key, _val := range packet.HashMap {
_val = strings.Replace(_val, "\n", " ", -1)
status = status && axnFunk(_key, _val)
}
}
return status
}