From 2f91f20a8645339385ada602684f4957f20f4da4 Mon Sep 17 00:00:00 2001 From: jloup Date: Thu, 22 Feb 2018 11:31:59 +0100 Subject: Poloniex connection. --- api/markets.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 api/markets.go (limited to 'api/markets.go') diff --git a/api/markets.go b/api/markets.go new file mode 100644 index 0000000..60fb912 --- /dev/null +++ b/api/markets.go @@ -0,0 +1,29 @@ +package api + +import ( + "immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front/markets" +) + +var Poloniex *markets.Poloniex + +func OpenMarketsConnection() error { + for { + err := Poloniex.StartTicker() + if err != nil { + return err + } + log.Warn("connection to poloniex stream ended, restarting it...") + } +} + +func init() { + Poloniex = markets.NewPoloniex() + + // We open markets connections in the background as it can take time. + go func() { + err := OpenMarketsConnection() + if err != nil { + ErrorChan <- err + } + }() +} -- cgit v1.2.3