Open amv opened 11 years ago
I think this should be a central feature. For it to be a central feature we probably need to make it easy and safe to use:
make sure there is only one version of the step 3 running at each time and that the internal state does not change during step 3.
As an implementation detail, you probably want to implement each action resulting from a /poll response as a job and push those jobs into a queue. This means changing both the internal and the FS state only within that job. You can safely not add a job for a /poll result if the result was the same as it was last time.
When you notice there are jobs in the queue, take all of the out simultaneously, process each of them both to the internal storage and to the FS, start the execution of the external script and after the script ends, return back to watching if the queue has jobs to process.
This way you guard yourself from the system getting into weird states due to the internal state changing concurrently in response of callbacks. The polls themselves can happen behind the scenes as they please.
There should be only one handler (at least for now) for each pollbal process.
For our use case, this should be the handler responsible of knowing which service version is active and create the resulting pools that the perlbal is actually expecting.
For future reference we can also create a couple of example scripts that would produce a proper nginx configuration and HUP nginx.
Currently there are multiple hooks. Lets at least not document them (nor maintain them if code around there changes) until we actually see a concrete use-case.
If anything in the pool configuration has changed, execute a configurable shell script (if configured).
However do this only after all pools have been checked and updated.
The purpose of this script would be to make sure any other program is actually aware of the new pool configuration. This might mean for example mungling the pool data in to an nginx configuration file and sending a HUP signal to nginx (or whatever makes it reread it's configs).