aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/worker_common.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-11-12 23:18:56 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-11-12 23:18:56 -0800
commitb03bfc8f3fd84141738f775b273a99850d78e1ff (patch)
tree64858e474fa38aa015f06f5e15b851dcc85da421 /python/fatcat_tools/worker_common.py
parent055c464deea8cdaccf3ed384995d4409b0f51409 (diff)
downloadfatcat-b03bfc8f3fd84141738f775b273a99850d78e1ff.tar.gz
fatcat-b03bfc8f3fd84141738f775b273a99850d78e1ff.zip
refactor python modules
Diffstat (limited to 'python/fatcat_tools/worker_common.py')
-rw-r--r--python/fatcat_tools/worker_common.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/python/fatcat_tools/worker_common.py b/python/fatcat_tools/worker_common.py
new file mode 100644
index 00000000..77ea2c15
--- /dev/null
+++ b/python/fatcat_tools/worker_common.py
@@ -0,0 +1,25 @@
+
+import re
+import sys
+import csv
+import json
+import itertools
+import fatcat_client
+from pykafka import KafkaClient
+from fatcat_client.rest import ApiException
+
+
+class FatcatWorker:
+ """
+ Common code for for Kafka producers and consumers.
+ """
+
+ def __init__(self, kafka_hosts, produce_topic=None, consume_topic=None, api_host_url=None):
+ if api_host_url:
+ conf = fatcat_client.Configuration()
+ conf.host = api_host_url
+ self.api = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))
+ self.kafka = KafkaClient(hosts=kafka_hosts, broker_version="1.0.0")
+ self.produce_topic = produce_topic
+ self.consume_topic = consume_topic
+