-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
Add a way to customize Hazelcast's Client/Server configs #19669
Conversation
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.
Thanks for the PR @nosan. Before we actually look at the code I would have preferred that we discuss what concrete use cases this is addressing. I know that there are some part of Config
that can't be set via config (and requires a Config
instance) but we have to balance the cost of adding more public APIs vs. what concrete problems adding a public API will solve.
Generally speaking, the idea of creating a customizer is helpful but I haven't heard a lot of requests in that direction. If you have some more concrete use cases that the management context, please let us know.
I'd also research how to improve what we have rather than creating yet another pair of factories for the client.
* @author Dmytro Nosan | ||
* @since 2.3.0 | ||
*/ | ||
public final class HazelcastClientConfigFactory { |
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.
This partially duplicates what HazelcastClientFactory
is doing. If that behaviour can/should be improved I don't think we should do it as part of this particular issue.
* @author Dmytro Nosan | ||
* @since 2.3.0 | ||
*/ | ||
public final class HazelcastConfigFactory { |
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.
Ditto. I also question the creation of such high-level concept for this. IMO this feels like Hazelcast itself should provide that.
*/ | ||
@Deprecated |
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.
Isn't that making HazelcastInstanceFactory
effectively deprecated? For the reason above, I don't think we should do that and rather research how to improve the existing class to account for the customizers.
@@ -5666,9 +5666,6 @@ If https://hazelcast.com/[Hazelcast] is on the classpath and a suitable configur | |||
If you define a `com.hazelcast.config.Config` bean, Spring Boot uses that. | |||
If your configuration defines an instance name, Spring Boot tries to locate an existing instance rather than creating a new one. | |||
|
|||
If you define a `com.hazelcast.config.Config` bean, Spring Boot uses that. | |||
If your configuration defines an instance name, Spring Boot tries to locate an existing instance rather than creating a new one. | |||
|
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.
This shouldn't be removed. If a user specifies an existing Config
we should use that rather than trying to lookup one.
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.
These are duplicates.
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.
Ah sorry, I missed that. Such polish must be done in a separate commit. I've addressed it in #19678
return (clientConfig) -> { | ||
SpringManagedContext managedContext = new SpringManagedContext(); | ||
managedContext.setApplicationContext(applicationContext); | ||
clientConfig.setManagedContext(managedContext); |
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.
Does it make sense to enable the management context in a Hazelcast client?
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.
Generally speaking, I don't know.
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.
@jerrinot can you please help here and let us know if it does?
Thank you for your feedback @snicoll
Unfortunately, I don't have any use cases. I've seen some snippets on StackOverflow, e.g. how to set a Of course, I understand that you will have to maintain this code and if you feel it is not worthy then feel free to close this PR. PR has been updated. I have removed additional factories that were used for configs creation. |
29ad12a
to
ef7eda4
Compare
Prior to this commit, there was no way to do this except creating your own config.
ef7eda4
to
dc26e23
Compare
Thanks @nosan. I feel that adding two new top-level interface is not warranted here. If it turns out the callback is required to implement the configuration of the |
@snicoll np, thanks |
This PR provides a way to customize Hazelcast's Client/Server configs before
HazelcastInstance
is created. At the moment there is no way to do this except creating your own config.Here is a small example of a configuration, that shows how to set
SpringManagedContext
using theHazelcastConfigCustomizer