ssl reloading: pull ownership of rebuilding into es client holder#1
Open
yaauie wants to merge 1 commit intokaisecheng:xpack-reload-certsfrom
Open
Conversation
Introduces a new `LogStash::Helpers::ElasticsearchClientHolder` that callers can use to get a current elasticsearch client WITHOUT needing to manage the state of that client. Provides two implementations, one of which is selected depending on whether a tracker is provided: - `Lazy`: simply creates the client on first use and returns the same client instance for all subsequent calls - `SslRebuildable`: similarly lazily creates the client on first use, but rebuilds clients that have been marked stale by the provided tracker before returning them to the caller.
🤖 GitHub commentsJust comment with:
|
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As-implemented in elastic#19045, callers of
LogStash::Helpers::SslRebuildableneed to manage the rebuild state of the client, and the singleLogStash::Helpers::SslRebuildableimplementation needed to be able to handle being instantiated without a tracker. This spreads the complexity across multiple classes.This PR is an alternative to that approach.
It introduces a new
LogStash::Helpers::ElasticsearchClientHolderthat callers can use to get a current elasticsearch client WITHOUT needing to manage the state of that client.It also provides two implementations, along with a routing function to select the correct implementation depending on whether a tracker is provided:
Lazy: simply creates the client on first use and returns the same client instance for all subsequent callsSslRebuildable: similarly lazily creates the client on first use, but rebuilds clients that have been marked stale by the provided tracker before returning them to the caller.The result is that the caller(s) don't need to be aware of certificate reloading and can simply use
LogStash::Helpers::ElasticsearchClientHolder#getto get a current client. The implementation handles the details of ensuring that the client it returns isn't stale.