Skip to content

Commit

Permalink
Merge pull request #106 from macielti/telegram-producer-to-telegram-c…
Browse files Browse the repository at this point in the history
…onsumer

`TelegramProducer` component as dependency for `TelegramConsumer`
  • Loading branch information
macielti committed Nov 27, 2023
2 parents de1ae16 + 45da511 commit 3d14c2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ of [keepachangelog.com](http://keepachangelog.com/).

## [Unreleased]

## [24.48.47] - 2023-11-27

## Added

- Add TelegramProducer component as dependency for TelegramConsumer component.

## [24.47.47] - 2023-11-26

## Added
Expand Down Expand Up @@ -635,7 +641,9 @@ of [keepachangelog.com](http://keepachangelog.com/).

- Add `loose-schema` function.

[Unreleased]: https://github.com/macielti/common-clj/compare/v24.47.47...HEAD
[Unreleased]: https://github.com/macielti/common-clj/compare/v24.48.47...HEAD

[24.48.47]: https://github.com/macielti/common-clj/compare/v24.47.47...v24.48.47

[24.47.47]: https://github.com/macielti/common-clj/compare/v24.46.47...v24.47.47

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject net.clojars.macielti/common-clj "24.47.47"
(defproject net.clojars.macielti/common-clj "24.48.47"
:description "Just common Clojure code that I use across projects"
:url "https://github.com/macielti/common-clj"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
14 changes: 8 additions & 6 deletions src/common_clj/component/telegram/consumer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
(doseq [update updates]
(consume-update! update consumers components))))

(defrecord TelegramConsumer [config http-client prometheus datomic jobs consumers]
(defrecord TelegramConsumer [config http-client prometheus datomic jobs consumers telegram-producer]
component/Lifecycle
(start [component]
(let [{{:keys [telegram] :as config-content} :config} config
Expand All @@ -117,7 +117,8 @@
:config config-content
:telegram-consumer bot
:jobs (:jobs jobs)
:prometheus (:prometheus prometheus))
:prometheus (:prometheus prometheus)
:telegram-producer (:telegram-producer telegram-producer))
pool (at-at/mk-pool)]
(at-at/interspaced 100 (fn []
(try (consumer-job! consumers components)
Expand All @@ -133,10 +134,10 @@

(defn new-telegram-consumer
[consumers]
(->TelegramConsumer {} {} {} {} {} consumers))
(->TelegramConsumer {} {} {} {} {} {} consumers))


(defrecord MockTelegramConsumer [config http-client datomic consumers]
(defrecord MockTelegramConsumer [config http-client datomic telegram-producer consumers]
component/Lifecycle
(start [component]
(let [pool (at-at/mk-pool)
Expand All @@ -147,7 +148,8 @@
components (medley/assoc-some {:telegram-consumer telegram-consumer-component}
:http-client (:http-client http-client)
:datomic (:datomic datomic)
:config (:config config))]
:config (:config config)
:telegram-producer (:telegram-producer telegram-producer))]

(at-at/interspaced 100 (fn []
(try (consumer-job! consumers components)
Expand All @@ -161,7 +163,7 @@

(defn new-mock-telegram-consumer
[consumers]
(->MockTelegramConsumer {} {} {} consumers))
(->MockTelegramConsumer {} {} {} {} consumers))

(s/defn insert-incoming-update!
[update
Expand Down

0 comments on commit 3d14c2a

Please sign in to comment.