Use direct assignment

This commit is contained in:
Julian Kornberger 2016-02-26 10:40:17 +01:00
parent 853e54065c
commit d2467bed77
3 changed files with 19 additions and 23 deletions

View File

@ -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{ return &Daemon{
collectors: []*Collector{
NewCollector("statistics", parseFunc), NewCollector("statistics", parseFunc),
NewCollector("nodeinfo", parseFunc), NewCollector("nodeinfo", parseFunc),
NewCollector("neighbours", parseFunc), NewCollector("neighbours", parseFunc),
} },
return &Daemon{
collectors,
} }
} }

View File

@ -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

View File

@ -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),
} }
} }