Last active
August 29, 2015 14:10
-
-
Save martinhynar/25abd9fb3e1ac88a9030 to your computer and use it in GitHub Desktop.
Correct usage of component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This is a function that needs 'resource' started/stopped by the component | |
(defn index-create [name] | |
(let [conn (esr/connect (es-url) {:connection-manager __HOW_TO_PASS_COMPONENT_HERE__})] | |
(esi/create conn name) | |
)) | |
;; A component that takes care of starting and stopping and stopping http connection manager | |
(defrecord ElasticSearch [] | |
component/Lifecycle | |
(start [this] | |
(let [cm (make-reusable-conn-manager (:connection-manager-conf this))] | |
(assoc this :connection-manager cm))) | |
(stop [this] | |
(let [cm (:connection-manager this)] | |
(shutdown-manager cm) | |
(assoc this :connection-manager nil))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment