Skip to content
Draft
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
9 changes: 8 additions & 1 deletion src/ketu/async/source.clj
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]
Expand Down Expand Up @@ -125,7 +126,10 @@

(loop []
(when-let [records (poll!)]
(run! put! records)
(if (seq records)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means an additional listTopics network 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.

(run! put! records)
; Throws exception if not connected
Copy link
Author

Choose a reason for hiding this comment

The 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)))
Copy link
Author

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -211,6 +215,9 @@
(defn done-chan [state]
(:ketu.source/consumer-thread state))

(defn closed? [consumer]
(-> consumer :ketu.source/out-chan async-protocols/closed?))
Copy link
Author

Choose a reason for hiding this comment

The 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)
Expand Down
Loading