-
-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC: watch config files to load/unload maps #948
base: master
Are you sure you want to change the base?
Conversation
4986f99
to
09528bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the direction I was initially thinking, but it seems workable. Things I'm worried about:
Leaking resources, especially database connections. I don't see providers being unregistered when shutting down. I've left a few comments. I will need to build this branch and play with it with a sample dataset.
Good catch, @gdey. My impression was that providers lived only as pointers on each map, but I didn't realize each driver/provider type is keeping track of its instantiated providers. This causes a couple problems with my approach:
Actually, if we add a |
… track their lifecyeles, thus removing this responsibility from the individual drivers.
94959ae
to
efb0451
Compare
Despite my previous comment, I ended up creating a global list of provider instances in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not forgotten this. My work has been focused on integrating our other systems with Tegola since Tegola is working well enough already, but I'll have some time later this month to get back to working on Tegola itself. I'll add the experimental guard to this PR as per @ARolek's request. |
This is a first draft to demonstrate an approach to solving for #944 (Dynamic loading of maps). This is not meant to be ready for merge, but I've run it locally and it works well so far.This is now ready for review. Please give it a spin, and I'd love your feedback on the acceptability of the overall approach. Thanks!New Abstraction
The central new idea/concept/abstraction is the "App". (I'm sure there's a better term for this, but bear with me.) An App is a collection of providers and maps which share a lifecycle. They are loaded into a Tegola instance as a unit and, when no longer needed, unloaded from Tegola as a unit.
The base TOML configuration file may contain an initial App which will never be unloaded. (Which is to say, the
[[providers]]
and[[maps]]
section of the TOML file still work exactly as expected.)Configuring Tegola to load Apps dynamically
A new, optional section is added to the base config,
[app_config_source]
. It includes atype
plus any options required for that source type. The only option for the "file" type isdir
which sets a directory from which to load apps.Add any TOML file to that directory and its
[[providers]]
and[[maps]]
will be registered immediately. Delete the file, and they'll be removed.Key Implementation Details
The
config/source
package has been added providingConfigSource
andConfigWatcher
(implemented only byFileConfigSource
so far):The
initConfig
process of Tegola's root command has been augmented withinitAppConfigSource()
, which starts a goroutine to receive updates and deletions from theConfigWatcher
channels.To ensure that apps are loaded and unloaded as a unit,
Atlas
has been given two new methods,AddMaps()
andRemoveMaps()
. Name collisions are checked before adding any maps toAtlas
, so that we don't quit partway through having added some maps but not others.