Use direct assignment
This commit is contained in:
parent
853e54065c
commit
d2467bed77
@ -9,13 +9,12 @@ type Daemon struct {
|
||||
|
||||
//NewDaemon create a list of collectors
|
||||
func NewDaemon(parseFunc func(coll *Collector, res *Response)) *Daemon {
|
||||
collectors := []*Collector{
|
||||
return &Daemon{
|
||||
collectors: []*Collector{
|
||||
NewCollector("statistics", parseFunc),
|
||||
NewCollector("nodeinfo", parseFunc),
|
||||
NewCollector("neighbours", parseFunc),
|
||||
}
|
||||
return &Daemon{
|
||||
collectors,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,14 @@ func NewClient(ws *websocket.Conn, server *Server) *Client {
|
||||
}
|
||||
|
||||
maxID++
|
||||
ch := make(chan interface{}, channelBufSize)
|
||||
doneCh := make(chan bool)
|
||||
|
||||
return &Client{maxID, ws, server, ch, doneCh}
|
||||
return &Client{
|
||||
id: maxID,
|
||||
ws: ws,
|
||||
server: server,
|
||||
ch: make(chan interface{}, channelBufSize),
|
||||
doneCh: make(chan bool),
|
||||
}
|
||||
}
|
||||
|
||||
//GetConnection the websocket connection of a listen client
|
||||
|
@ -21,21 +21,14 @@ type Server struct {
|
||||
|
||||
//NewServer creates a new server
|
||||
func NewServer(pattern string) *Server {
|
||||
clients := make(map[int]*Client)
|
||||
addCh := make(chan *Client)
|
||||
delCh := make(chan *Client)
|
||||
sendAllCh := make(chan interface{})
|
||||
closeCh := make(chan bool)
|
||||
errCh := make(chan error)
|
||||
|
||||
return &Server{
|
||||
pattern,
|
||||
clients,
|
||||
addCh,
|
||||
delCh,
|
||||
sendAllCh,
|
||||
closeCh,
|
||||
errCh,
|
||||
pattern: pattern,
|
||||
clients: make(map[int]*Client),
|
||||
addCh: make(chan *Client),
|
||||
delCh: make(chan *Client),
|
||||
sendAllCh: make(chan interface{}),
|
||||
closeCh: make(chan bool),
|
||||
errCh: make(chan error),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user