Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
46f2289d
Commit
46f2289d
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/events.clj
+10
-2
10 additions, 2 deletions
src/metabase/events.clj
src/metabase/task.clj
+10
-2
10 additions, 2 deletions
src/metabase/task.clj
with
20 additions
and
4 deletions
src/metabase/events.clj
+
10
−
2
View file @
46f2289d
(
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!
...
...
This diff is collapsed.
Click to expand it.
src/metabase/task.clj
+
10
−
2
View file @
46f2289d
(
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!
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment