ajpauwels / pit-of-vipers

Managing many viper instances
MIT License
10 stars 1 forks source link

question: does/could this support viper remote with consul #2

Open c-nv-s opened 2 years ago

c-nv-s commented 2 years ago

could this also support viper instances that also use github.com/spf13/viper/remote which calls the AddRemoteProvider() function ? e.g. https://madflojo.medium.com/using-viper-with-consul-to-configure-golang-applications-eaa84394b8de

ajpauwels commented 2 years ago

It does not currently, but it could.

It looks like the "watch" functionality on the remote providers doesn't really leverage any of the push-based dynamic updates. Viper instructs you to setup a separate goroutine on a timer that polls the remote source for an update regularly.

It would be fairly trivial to set-up this timer within the pit-of-vipers code, check the remote for an update, and merge it in using the exact same code used to merge in updates from the fs.

I'll try adding this in within the next few days.

ajpauwels commented 2 years ago

If you'd like to test out this PR, it should add support for remote config watching through a new constructor: https://github.com/ajpauwels/pit-of-vipers/pull/3

I've intentionally not broken the existing API to make this a minor version bump, the next major version will replace the existing constrictor with the new style.

If you could test that'd be great as I don't currently have access to a remote store.

c-nv-s commented 2 years ago

thanks a lot, It'll have to be ~mid-next week because I've got a deadline and some things to sort before I can test it but I'll report back asap

ajpauwels commented 2 years ago

no problem, hope pit-of-vipers is able to help you out :)

c-nv-s commented 2 years ago

finally got around to trying to test this out, however I can't seem to get it working. couldn't find a way to properly pass the viperpit.Config{} as the struct values seem to be unexported ? so even using viperpit.Config{true, 30} you see the message: implicit assignment of unexported field 'watchRemote' in config.Config literal