from kafka_tfrx.stream import KafkaStream from kryptoflow.scrapers.reddit import RedditStreamer from kryptoflow.managers.project import ProjectManager if __name__ == '__main__': schemas = ProjectManager.get_value('kafka')['schemas'] secrets = ProjectManager.get_secrets('reddit') sink = KafkaStream.avro_producer(schemas=schemas, topic='reddit') r = RedditStreamer(producer=sink, reddit_config=secrets) r.start_stream()
def test_setup_avro_producer(): p = KafkaStream.avro_producer('gdax', schemas='tests/sample_schemas') assert isinstance(p, AvroProducer) with pytest.raises(ValueError): KafkaStream.avro_producer('gdax', schemas=None)
from kafka_tfrx.stream import KafkaStream from kryptoflow.scrapers.gdax_ws import GDAXClient from kryptoflow.managers.project import ProjectManager if __name__ == '__main__': schemas = ProjectManager.get_value('kafka')['schemas'] sink = KafkaStream.avro_producer(topic='gdax', ip='localhost', schemas=schemas) gd = GDAXClient(products=['BTC-USD'], channels=['ticker'], producer=sink) gd.start_stream()
from kafka_tfrx.stream import KafkaStream """ Assumes kafka and schema registry are running according to the following configuration: https://github.com/carlomazzaferro/kryptoflow/blob/master/docker-compose.yml """ if __name__ == '__main__': msg = {"price": 100.0, "volume_24h": 10000.1, "spread": 0, "ts": "1235467", "side": "buy"} p = KafkaStream.avro_producer('gdax', schemas='examples/schemas', ip='127.0.0.1') for i in range(100): p.produce(topic='gdax', value=msg) p.flush()