Implement ingesting to Logstash
This commit is contained in:
@@ -14,6 +14,7 @@ import util
|
||||
from lib.agoradesk_py import AgoraDesk
|
||||
from lib.localbitcoins_py import LocalBitcoins
|
||||
import db
|
||||
from lib.logstash import send_logstash
|
||||
|
||||
|
||||
class Local(util.Base):
|
||||
@@ -319,7 +320,6 @@ class Local(util.Base):
|
||||
ads = yield self.api.buy_monero_online(currency_code=currency, page=page)
|
||||
elif asset == "BTC":
|
||||
ads = yield self.api.buy_bitcoins_online(currency_code=currency, page=page)
|
||||
|
||||
# with open("pub.json", "a") as f:
|
||||
# import json
|
||||
# f.write(json.dumps([page, currency, asset, ads])+"\n")
|
||||
@@ -451,22 +451,24 @@ class Local(util.Base):
|
||||
return public_ads
|
||||
|
||||
def write_to_es_ads(self, msgtype, ads):
|
||||
if settings.ES.Enabled == "1":
|
||||
for ad in ads:
|
||||
cast = {
|
||||
"id": ad[0],
|
||||
"username": ad[1],
|
||||
"price": ad[2],
|
||||
"provider": ad[3],
|
||||
"asset": ad[4],
|
||||
"currency": ad[5],
|
||||
"margin": ad[6],
|
||||
"type": msgtype,
|
||||
"ts": str(datetime.now().isoformat()),
|
||||
"xtype": "platform",
|
||||
"market": self.platform,
|
||||
}
|
||||
for ad in ads:
|
||||
cast = {
|
||||
"id": ad[0],
|
||||
"username": ad[1],
|
||||
"price": ad[2],
|
||||
"provider": ad[3],
|
||||
"asset": ad[4],
|
||||
"currency": ad[5],
|
||||
"margin": ad[6],
|
||||
"ts": str(datetime.now().isoformat()),
|
||||
"xtype": msgtype,
|
||||
"market": self.platform,
|
||||
"type": "platform",
|
||||
}
|
||||
if settings.ES.Enabled == "1":
|
||||
self.es.index(index=settings.ES.MetaIndex, body=cast)
|
||||
elif settings.Logstash.Enabled == "1":
|
||||
send_logstash(cast)
|
||||
|
||||
@inlineCallbacks
|
||||
def slow_ad_update(self, ads):
|
||||
|
||||
Reference in New Issue
Block a user