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
db63b9f9
Commit
db63b9f9
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Plain Diff
Merge pull request #1529 from metabase/driver-init
Possible tweaks to driver initialization path
parents
b9cd2393
546b528a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/core.clj
+4
-0
4 additions, 0 deletions
src/metabase/core.clj
src/metabase/driver.clj
+10
-8
10 additions, 8 deletions
src/metabase/driver.clj
test/metabase/test_setup.clj
+5
-0
5 additions, 0 deletions
test/metabase/test_setup.clj
with
19 additions
and
8 deletions
src/metabase/core.clj
+
4
−
0
View file @
db63b9f9
...
...
@@ -15,6 +15,7 @@
[
medley.core
:as
m
]
(
metabase
[
config
:as
config
]
[
db
:as
db
]
[
driver
:as
driver
]
[
events
:as
events
]
[
middleware
:as
mb-middleware
]
[
routes
:as
routes
]
...
...
@@ -122,6 +123,9 @@
(
.addShutdownHook
(
Runtime/getRuntime
)
(
Thread.
^
Runnable
destroy
))
(
reset!
metabase-initialization-progress
0.3
)
;; Load up all of our Database drivers, which are used for app db work
(
driver/find-and-load-drivers!
)
;; startup database. validates connection & runs any necessary migrations
(
db/setup-db
:auto-migrate
(
config/config-bool
:mb-db-automigrate
))
(
reset!
metabase-initialization-progress
0.5
)
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver.clj
+
10
−
8
View file @
db63b9f9
...
...
@@ -231,23 +231,25 @@
(
swap!
registered-drivers
assoc
engine
driver-instance
)
(
log/debug
(
format
"Registered driver %s."
engine
)))
(
def
^
:private
load-driver-namespaces!
"Search the classpath for metabase driver namespaces and `require` them, so they are \"registered\" and can be used :heart_eyes_cat:"
(
delay
(
doseq
[
namespce
(
filter
(
fn
[
ns-symb
]
(
re-matches
#
"^metabase\.driver\.[a-z0-9_]+$"
(
name
ns-symb
)))
(
ns-find/find-namespaces
(
classpath/classpath
)))]
(
require
namespce
))))
(
defn
available-drivers
"Info about available drivers."
[]
@
load-driver-namespaces!
(
m/map-vals
(
fn
[
driver
]
{
:details-fields
(
details-fields
driver
)
:driver-name
(
name
driver
)
:features
(
features
driver
)})
@
registered-drivers
))
(
defn
find-and-load-drivers!
"Search Classpath for namespaces that start with `metabase.driver.`, then `require` them and look for the `driver-init`
function which provides a uniform way for Driver initialization to be done."
[]
(
doseq
[
namespce
(
filter
(
fn
[
ns-symb
]
(
re-matches
#
"^metabase\.driver\.[a-z0-9_]+$"
(
name
ns-symb
)))
(
ns-find/find-namespaces
(
classpath/classpath
)))]
(
log/info
"loading driver namespace: "
namespce
)
(
require
namespce
)))
(
defn
is-engine?
"Is ENGINE a valid driver name?"
[
engine
]
...
...
This diff is collapsed.
Click to expand it.
test/metabase/test_setup.clj
+
5
−
0
View file @
db63b9f9
...
...
@@ -6,6 +6,7 @@
[
expectations
:refer
:all
]
(
metabase
[
core
:as
core
]
[
db
:as
db
]
[
driver
:as
driver
]
[
util
:as
u
])
(
metabase.models
[
setting
:as
setting
]
[
table
:refer
[
Table
]])
...
...
@@ -65,6 +66,10 @@
;; # ------------------------------ FUNCTIONS THAT GET RUN ON TEST SUITE START / STOP ------------------------------
;; this is a little odd, but our normal `test-startup` function won't work for loading the drivers because
;; they need to be available at evaluation time for some of the unit tests work work properly, so we put this here
(
defonce
^
:private
loaded-drivers
(
driver/find-and-load-drivers!
))
(
defn-
load-test-data!
"Call `load-data!` on all the datasets we're testing against."
[]
...
...
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