From ea2316d71d816b1c5a8fcccf69ed6f2938e66c4b Mon Sep 17 00:00:00 2001 From: marcosschroh Date: Tue, 11 Jun 2019 22:45:00 +0200 Subject: [PATCH] fix: Dependencies updated. --- faust-project/example/app.py | 1 + faust-project/example/codecs/avro.py | 9 ++----- faust-project/example/codecs/serializers.py | 30 --------------------- faust-project/setup.py | 7 +++-- 4 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 faust-project/example/codecs/serializers.py diff --git a/faust-project/example/app.py b/faust-project/example/app.py index b689193..92ab279 100644 --- a/faust-project/example/app.py +++ b/faust-project/example/app.py @@ -15,3 +15,4 @@ def main() -> None: app.main() + diff --git a/faust-project/example/codecs/avro.py b/faust-project/example/codecs/avro.py index 67a5f58..7379299 100644 --- a/faust-project/example/codecs/avro.py +++ b/faust-project/example/codecs/avro.py @@ -1,11 +1,10 @@ from avro.schema import SchemaFromJSONData from schema_registry.client import SchemaRegistryClient +from schema_registry.serializers import FaustSerializer from simple_settings import settings -from .serializers import AvroSerializer - # Initialize Schema Registry Client client = SchemaRegistryClient(url=settings.SCHEMA_REGISTRY_URL) @@ -20,11 +19,7 @@ ] }) -avro_user_serializer = AvroSerializer( - schema_registry_client=client, - destination_topic="users", - schema=avro_user_schema -) +avro_user_serializer = FaustSerializer(client, "users", avro_user_schema) def avro_user_codec(): diff --git a/faust-project/example/codecs/serializers.py b/faust-project/example/codecs/serializers.py deleted file mode 100644 index 260af46..0000000 --- a/faust-project/example/codecs/serializers.py +++ /dev/null @@ -1,30 +0,0 @@ -from faust.serializers.codecs import Codec - -from schema_registry.serializer import MessageSerializer - -from typing import Dict - - -class AvroSerializer(MessageSerializer, Codec): - - def __init__(self, schema_registry_client, destination_topic, - schema, is_key=False): - self.schema_registry_client = schema_registry_client - self.destination_topic = destination_topic - self.schema = schema - self.is_key = is_key - - # Initialize parents - MessageSerializer.__init__(self, schema_registry_client) - Codec.__init__(self) - - def _loads(self, s: bytes) -> Dict: - return self.decode_message(s) - - def _dumps(self, obj: Dict) -> bytes: - return self.encode_record_with_schema( - self.destination_topic, - self.schema, - obj, - is_key=self.is_key - ) diff --git a/faust-project/setup.py b/faust-project/setup.py index 80155c9..5d902c3 100644 --- a/faust-project/setup.py +++ b/faust-project/setup.py @@ -4,16 +4,15 @@ "avro-python3", "colorlog==3.1.4", "fastavro", - "faust==1.5.4", - "robinhood-aiokafka==1.0.2", + "robinhood-aiokafka==1.0.3", "requests==2.22.0", "simple-settings==0.16.0", - "python-schema-registry-client==0.2.4", + "python-schema-registry-client[faust]==0.3.0", ] setup( name='faust-example', - version='1.1.1', + version='1.1.2', description='Faust example with Docker Compose', long_description=''' Example running Faust with Docker Compose (zookeeper, kafka and schema-registry)