Skip to content
Snippets Groups Projects
Commit 46f2289d authored by Allen Gilliland's avatar Allen Gilliland
Browse files

be more idiomatic and update docstrings to better describe how the initialization pattern works.

parent 6063a6c3
No related branches found
No related tags found
No related merge requests found
(ns metabase.events
"Provides a very simply event bus using `core.async` to allow publishing and subscribing to intersting
topics happening throughout the Metabase system in a decoupled way."
topics happening throughout the Metabase system in a decoupled way.
## Regarding Events Initialization:
The most appropriate way to initialize event listeners in any `metabase.events.*` namespace is to implement the
`events-init` function which accepts zero arguments. This function is dynamically resolved and called exactly
once when the application goes through normal startup procedures. Inside this function you can do any work
needed and add your events subscribers to the bus as usual via `start-event-listener`."
(:require clojure.java.classpath
[clojure.core.async :as async]
[clojure.tools.logging :as log]
......@@ -23,7 +30,8 @@
(map (fn [events-ns]
(log/info "\tloading events namespace: " events-ns)
(require events-ns)
((ns-resolve events-ns (symbol "events-init")))))
;; look for `events-init` function in the namespace and call it if it exists
((ns-resolve events-ns 'events-init))))
dorun))
(defn initialize-events!
......
(ns metabase.task
"Background task scheduling via Quartzite. Individual tasks are defined in `metabase.task.*`"
"Background task scheduling via Quartzite. Individual tasks are defined in `metabase.task.*`.
## Regarding Task Initialization:
The most appropriate way to initialize tasks in any `metabase.task.*` namespace is to implement the
`task-init` function which accepts zero arguments. This function is dynamically resolved and called
exactly once when the application goes through normal startup procedures. Inside this function you
can do any work needed and add your task to the scheduler as usual via `schedule-task!`."
(:require clojure.java.classpath
[clojure.tools.logging :as log]
[clojure.tools.namespace.find :as ns-find]
......@@ -19,7 +26,8 @@
(map (fn [events-ns]
(log/info "\tloading tasks namespace: " events-ns)
(require events-ns)
((ns-resolve events-ns (symbol "task-init")))))
;; look for `task-init` function in the namespace and call it if it exists
((ns-resolve events-ns 'task-init))))
dorun))
(defn start-scheduler!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment