gdax: some updates
This commit is contained in:
parent
f39f1aefbe
commit
4e82c44a50
@ -1,8 +1,8 @@
|
||||
package gdax
|
||||
|
||||
type Client interface {
|
||||
type ListenerClient interface {
|
||||
Open() error
|
||||
Close()
|
||||
Close() error
|
||||
Send(msg Request)
|
||||
Stream() <-chan Message
|
||||
Error() <-chan error
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type ListenerService struct {
|
||||
Client Client
|
||||
Client ListenerClient
|
||||
Logger tacitus.Logger
|
||||
|
||||
trades chan tacitus.Trade
|
||||
@ -16,7 +16,8 @@ type ListenerService struct {
|
||||
|
||||
subs []string
|
||||
|
||||
closed bool
|
||||
closed bool
|
||||
|
||||
shouldRestart bool
|
||||
restMu sync.Mutex
|
||||
|
||||
@ -44,11 +45,13 @@ func (s *ListenerService) Open() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *ListenerService) Close() {
|
||||
func (s *ListenerService) Close() error {
|
||||
s.closed = true
|
||||
s.setRestart(false)
|
||||
s.Client.Close()
|
||||
s.Logger.Info("GDAX listener stopped")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ListenerService) Subscribe(products ...string) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const ENDPOINT = "wss://ws-feed.gdax.com"
|
||||
const endpoint = "wss://ws-feed.gdax.com"
|
||||
|
||||
type Client struct {
|
||||
msgs chan gdax.Message
|
||||
@ -32,7 +32,7 @@ func NewClient() *Client {
|
||||
func (c *Client) Open() error {
|
||||
var err error
|
||||
|
||||
c.conn, _, err = websocket.DefaultDialer.Dial(ENDPOINT, nil)
|
||||
c.conn, _, err = websocket.DefaultDialer.Dial(endpoint, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -83,8 +83,10 @@ func (c *Client) Open() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Close() {
|
||||
func (c *Client) Close() error {
|
||||
c.sendClose(true)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) sendClose(send bool) {
|
||||
|
Reference in New Issue
Block a user