kucoin: implement getEndpoint method

This commit is contained in:
c9s 2021-12-23 00:45:59 +08:00
parent a4c9aea6c6
commit b0d4688528
2 changed files with 21 additions and 8 deletions

View File

@ -57,7 +57,6 @@ var websocketCmd = &cobra.Command{
}
u, err := bullet.URL()
if err != nil {
return err

View File

@ -144,19 +144,33 @@ func (s *Stream) Reconnector(ctx context.Context) {
}
}
func (s *Stream) getEndpoint() string {
var url string
// getEndpoint use the publicOnly flag to check whether we should allocate a public bullet or private bullet
func (s *Stream) getEndpoint() (string, error) {
var bullet *kucoinapi.Bullet
var err error
if s.publicOnly {
url = "XXX"
bullet, err = s.Client.BulletService.NewGetPublicBulletRequest().Do(nil)
} else {
url = "XXX"
bullet, err = s.Client.BulletService.NewGetPrivateBulletRequest().Do(nil)
}
return url
if err != nil {
return "", err
}
url, err := bullet.URL()
if err != nil {
return "", err
}
return url.String(), nil
}
func (s *Stream) connect(ctx context.Context) error {
// when in public mode, the listen key is an empty string
var url = s.getEndpoint()
url, err := s.getEndpoint()
if err != nil {
return err
}
conn, err := s.StandardStream.Dial(url)
if err != nil {