-
Notifications
You must be signed in to change notification settings - Fork 10
Better disconnection handling #21
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| (ns ketu.async.source | ||
| (:require [clojure.core.async :as async] | ||
| [clojure.core.async.impl.protocols :as async-protocols] | ||
| [ketu.async.util :as util] | ||
| [ketu.clients.consumer :as consumer] | ||
| [ketu.shape.consumer :as shape] | ||
|
|
@@ -125,7 +126,10 @@ | |
|
|
||
| (loop [] | ||
| (when-let [records (poll!)] | ||
| (run! put! records) | ||
| (if (seq records) | ||
| (run! put! records) | ||
| ; Throws exception if not connected | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want automatic recovery? or does it belong in the application / wrapper library? |
||
| (.listTopics consumer (Duration/ofMillis 5000))) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add one more timeout field to the config perhaps? |
||
| (recur))) | ||
|
|
||
| (catch WakeupException e | ||
|
|
@@ -211,6 +215,9 @@ | |
| (defn done-chan [state] | ||
| (:ketu.source/consumer-thread state)) | ||
|
|
||
| (defn closed? [consumer] | ||
| (-> consumer :ketu.source/out-chan async-protocols/closed?)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can also use done-chan |
||
|
|
||
| (defn- wait-for-the-thread! [state] | ||
| (let [consumer-thread (:ketu.source/consumer-thread state) | ||
| consumer-thread-timeout-ms (-> state :ketu/source-opts :ketu.source/consumer-thread-timeout-ms) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this means an additional
listTopicsnetwork call every time an empty poll is received. Might have performance/load implications? I doubt it, since it only happens when 0 lag and the call should be pretty lightweight.