Sync Gateway's ServerContext contains a reference to a "BootstrapConnection" interface, which has 4 methods:
- List available buckets
- Get, Insert, and Update a database config within a given bucket
The current persistent config implementation (CouchbaseCluster) opens a new SDK connection for each operation it does (list buckets, get config, etc.)
This was to work around an issue where a single SDK connection cannot operate on different buckets, but is too expensive to open for each operation we do (~2 seconds)
At a high-level, we should make the implementation initialize connections for a) the cluster (to list buckets), and b) for each bucket we find/use.
We need to handle the cases where:
- buckets are dropped or added to the server whilst this code is still running
- We can probably do this by making "GetConfigBuckets" add/remove connections to buckets based on the list returned
- the connection is dropped, due to a network blip
- It might be that on an error, we retry, or we just log about it, remove the now invalid connection reference, and let the code re-initialize it
We don't need to consider using these bucket connections for other SG database operations, as those can use different authentication credentials than the bootstrap/config process.
Functionality remains the same.
As a side-effect, persistent config loads are quicker as they do not need to set up an entirely new SDK connection every time...
Handles the above exceptional cases gracefully (bucket added/removed, connection drops) without needing to restart SG