mirror of
https://github.com/eosswedenorg/thalos
synced 2026-08-23 19:48:12 +02:00
api/client.go: some comments.
This commit is contained in:
parent
e69ff9781f
commit
0d8ecaea36
1 changed files with 4 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ type Client struct {
|
||||||
reader Reader
|
reader Reader
|
||||||
decoder message.Decoder
|
decoder message.Decoder
|
||||||
|
|
||||||
|
// waitgroup for worker threads.
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
OnError func(error)
|
OnError func(error)
|
||||||
|
|
@ -42,6 +43,7 @@ func (c *Client) worker(channel Channel, h handler) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action handler
|
||||||
func (c *Client) actHandler(payload []byte) {
|
func (c *Client) actHandler(payload []byte) {
|
||||||
var act message.ActionTrace
|
var act message.ActionTrace
|
||||||
if err := c.decoder(payload, &act); err != nil {
|
if err := c.decoder(payload, &act); err != nil {
|
||||||
|
|
@ -53,6 +55,7 @@ func (c *Client) actHandler(payload []byte) {
|
||||||
c.OnAction(act)
|
c.OnAction(act)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HeartBeat handler
|
||||||
func (c *Client) hbHandler(payload []byte) {
|
func (c *Client) hbHandler(payload []byte) {
|
||||||
var hb message.HeartBeat
|
var hb message.HeartBeat
|
||||||
if err := c.decoder(payload, &hb); err != nil {
|
if err := c.decoder(payload, &hb); err != nil {
|
||||||
|
|
@ -87,6 +90,7 @@ func (c *Client) Subscribe(channel Channel) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Run() {
|
func (c *Client) Run() {
|
||||||
|
// Just wait for workers to complete.
|
||||||
c.wg.Wait()
|
c.wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue