-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
89 lines (77 loc) · 2.45 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
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
package drift
import (
"log"
"github.com/mayur-tolexo/aqua"
nsq "github.com/nsqio/go-nsq"
)
//AddConstumer is the request format of add consumer api
type AddConstumer struct {
LookupHTTPAddr []string `json:"lookup_http_address"`
NsqDTCPAddrs []string `json:"nsqd_tcp_address"`
Topic []TopicData `json:"topic_detail"`
MaxInFlight int `json:"max_in_flight"`
StartAdmin bool `json:"start_admin"`
}
//KillConsumer is the request format of kill consumer api
type KillConsumer struct {
Topic string `json:"topic"`
Channel string `json:"channel"`
Count int `json:"count"`
}
//Publish is the request format of publish request api
type Publish struct {
NsqDTCPAddrs []string `json:"nsqd_tcp_address"`
Topic string `json:"topic"`
Data interface{} `json:"data"`
}
//TopicData will contail the topic details
type TopicData struct {
Topic string `json:"topic"`
Channel string `json:"channel"`
Count int `json:"count"`
}
//AddAdmin is the add admin request
type AddAdmin struct {
AdminUser []string `json:"user"`
HTTPAddrs string `json:"http_address"`
LookupHTTPAddr []string `json:"lookup_http_address"`
NsqDTCPAddrs []string `json:"nsqd_tcp_address"`
ACLHTTPHeader string `json:"acl_http_header"`
NotificationHTTPEndpoint string `json:"notification_http_endpoint"`
}
//Admin is the request format of admin api to permorm action.
//allowed actions are - create/empty/delete/pause/unpause
type Admin struct {
Topic string `json:"topic"`
Channel string `json:"channel"`
Action string `json:"action"`
}
//tailHandler will implement the nsq handler
type tailHandler struct {
topicName string
jobHandler JobHandler
}
//JobHandler function which will be called
type JobHandler func(value ...interface{}) error
//Drift have the consumer/publisher model
type Drift struct {
Server aqua.RestServer
chanelHandler map[string]JobHandler
jobHandler JobHandler
consumers map[string][]*nsq.Consumer
pubAddrs []string
admin dAdmin
logger *log.Logger
logLevel LogLevel
}
//dAdmin have the drift admin model
type dAdmin struct {
adminUser []string
httpAddrs string
lookupHTTPAddr []string
nsqDTCPAddrs []string
aclHTTPHeader string
notificationHTTPEndpoint string
adminRunning bool
exitAdmin chan int
}