From c6693c5f2e2c7ad5386cfef0843a78bde0a20ba1 Mon Sep 17 00:00:00 2001 From: Fredrik Rosenqvist Date: Mon, 1 Jul 2019 14:54:20 +0200 Subject: [PATCH 1/4] Raise exception if QUEUE_SERVICE_HOST is missing --- worker/worker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/worker/worker.py b/worker/worker.py index 99f6f60..68aa2cc 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -13,6 +13,10 @@ def __init__(self, queue_name, handler, logger): self.queue_name = queue_name self.handler = handler self.logger = logger + + if settings.QUEUE_SERVICE_HOST is None: + raise Exception("aws-sqs-worker is missing a 'QUEUE_SERVICE_HOST' environment variable") + self.client = request_client.Client(settings.QUEUE_SERVICE_HOST) self.run = True From b64c3ff921cc0235f62e2e5c0d08bf0d41055a58 Mon Sep 17 00:00:00 2001 From: Fredrik Rosenqvist Date: Mon, 1 Jul 2019 14:59:29 +0200 Subject: [PATCH 2/4] Add support for liveness callback --- worker/worker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/worker/worker.py b/worker/worker.py index 68aa2cc..eaf7480 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -9,10 +9,11 @@ class QueueServiceWorker: - def __init__(self, queue_name, handler, logger): + def __init__(self, queue_name, handler, logger, liveness_callback): self.queue_name = queue_name self.handler = handler self.logger = logger + self.liveness_callback = liveness_callback if settings.QUEUE_SERVICE_HOST is None: raise Exception("aws-sqs-worker is missing a 'QUEUE_SERVICE_HOST' environment variable") @@ -79,6 +80,9 @@ def _work(self): else: raise Exception('Unhandled error {}', message_type) + if self.liveness_callback is not None: + self.liveness_callback() + self.logger.info('Work loop exited') def start(self): From 60e2d8dac42ac48f39e181254bf0915c0b652ac2 Mon Sep 17 00:00:00 2001 From: Fredrik Rosenqvist Date: Mon, 1 Jul 2019 15:26:14 +0200 Subject: [PATCH 3/4] Let liveness_callback default to None --- worker/worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/worker.py b/worker/worker.py index eaf7480..d8aa292 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -9,7 +9,7 @@ class QueueServiceWorker: - def __init__(self, queue_name, handler, logger, liveness_callback): + def __init__(self, queue_name, handler, logger, liveness_callback=None): self.queue_name = queue_name self.handler = handler self.logger = logger From bd41be89509d776870df8a44e2f3eb5917ff07b0 Mon Sep 17 00:00:00 2001 From: Fredrik Rosenqvist Date: Mon, 1 Jul 2019 15:29:59 +0200 Subject: [PATCH 4/4] Prepare for bumping version to v0.0.2 --- README.md | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9b9b2e1..4184044 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,12 @@ This module exposes the necessary API to create a worker which starts polling me We can install the library through github by writing the dependency in `requirements.txt` as: ``` -https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.1/aws_sqs_worker-0.0.1-py3-none-any.whl +https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.2/aws_sqs_worker-0.0.2-py3-none-any.whl ``` -Replace 0.0.1 with the desired version, on both places in the url! +Replace 0.0.2 with the desired version, on both places in the url! -If using pipenv, you can also run `pipenv install https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.1/aws_sqs_worker-0.0.1-py3-none-any.whl`. +If using pipenv, you can also run `pipenv install https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.2/aws_sqs_worker-0.0.2-py3-none-any.whl`. ## Steps necessary to create a worker for the process: diff --git a/setup.py b/setup.py index 510af92..3e3a381 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='aws-sqs-worker', - version='0.0.1', + version='0.0.2', description='AWS SQS Worker Module', license='MIT', long_description=long_description,