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
|
//NewDaemon create a list of collectors
|
||||||
func NewDaemon(parseFunc func(coll *Collector, res *Response)) *Daemon {
|
func NewDaemon(parseFunc func(coll *Collector, res *Response)) *Daemon {
|
||||||
collectors := []*Collector{
|
|
||||||
NewCollector("statistics", parseFunc),
|
|
||||||
NewCollector("nodeinfo", parseFunc),
|
|
||||||
NewCollector("neighbours", parseFunc),
|
|
||||||
}
|
|
||||||
return &Daemon{
|
return &Daemon{
|
||||||
collectors,
|
collectors: []*Collector{
|
||||||
|
NewCollector("statistics", parseFunc),
|
||||||
|
NewCollector("nodeinfo", parseFunc),
|
||||||
|
NewCollector("neighbours", parseFunc),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +31,14 @@ func NewClient(ws *websocket.Conn, server *Server) *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maxID++
|
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
|
//GetConnection the websocket connection of a listen client
|
||||||
|
@ -21,21 +21,14 @@ type Server struct {
|
|||||||
|
|
||||||
//NewServer creates a new server
|
//NewServer creates a new server
|
||||||
func NewServer(pattern string) *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{
|
return &Server{
|
||||||
pattern,
|
pattern: pattern,
|
||||||
clients,
|
clients: make(map[int]*Client),
|
||||||
addCh,
|
addCh: make(chan *Client),
|
||||||
delCh,
|
delCh: make(chan *Client),
|
||||||
sendAllCh,
|
sendAllCh: make(chan interface{}),
|
||||||
closeCh,
|
closeCh: make(chan bool),
|
||||||
errCh,
|
errCh: make(chan error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user