Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a delay when restarting handle-queue #6

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject motiva/sqs-utils "0.3.0-SNAPSHOT"
(defproject motiva/sqs-utils "0.2.3-SNAPSHOT"
:description "Higher level SQS utilities for use in Motiva products"
:url "https://github.com/Motiva-AI/sqs-utils"
:license {:name "MIT License"
Expand Down
11 changes: 8 additions & 3 deletions src/sqs_utils/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
([sqs-config queue-url out-chan]
(receive-loop! sqs-config queue-url out-chan {}))

([sqs-config queue-url out-chan {:keys [auto-delete visibility-timeout]
:or {auto-delete true
visibility-timeout 60}
([sqs-config queue-url out-chan {:keys [auto-delete visibility-timeout restart-delay-seconds]
:or {auto-delete true
visibility-timeout 60
restart-delay-seconds 1}
:as opts}]
(let [loop-state (atom {:messages
(sqs.channeled/receive!
Expand Down Expand Up @@ -124,6 +125,10 @@
(log/warn message "Received an error from fink-nottle"
(assoc stats :last-wait-duration (secs-between this-pass-started-at
(t/now))))
;; Adding a restart delay so that this doesn't go into an
;; infinite loop if the queue listener is failing to start
;; continuously.
(<! (async/timeout (int (* restart-delay-seconds 1000))))
(restart-loop))

;; it's a well formed actionable message
Expand Down