mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +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
|
||||
decoder message.Decoder
|
||||
|
||||
// waitgroup for worker threads.
|
||||
wg sync.WaitGroup
|
||||
|
||||
OnError func(error)
|
||||
|
|
@ -42,6 +43,7 @@ func (c *Client) worker(channel Channel, h handler) {
|
|||
}
|
||||
}
|
||||
|
||||
// Action handler
|
||||
func (c *Client) actHandler(payload []byte) {
|
||||
var act message.ActionTrace
|
||||
if err := c.decoder(payload, &act); err != nil {
|
||||
|
|
@ -53,6 +55,7 @@ func (c *Client) actHandler(payload []byte) {
|
|||
c.OnAction(act)
|
||||
}
|
||||
|
||||
// HeartBeat handler
|
||||
func (c *Client) hbHandler(payload []byte) {
|
||||
var hb message.HeartBeat
|
||||
if err := c.decoder(payload, &hb); err != nil {
|
||||
|
|
@ -87,6 +90,7 @@ func (c *Client) Subscribe(channel Channel) error {
|
|||
}
|
||||
|
||||
func (c *Client) Run() {
|
||||
// Just wait for workers to complete.
|
||||
c.wg.Wait()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue