-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Allow in-memory client registration repos to be constructed with a map #5918
Allow in-memory client registration repos to be constructed with a map #5918
Conversation
@vpavic This makes sense to allow However, I'm not keen on deprecating Please go ahead and add |
Also, what are your thoughts on just adding |
It is a naming concern. If something can be backed by a distributed map like Hazelcast's
It sounds like an unnecessary duplication to me. With |
The naming convention
Agreed that this can be confusing if the user were to implement this way. An alternative implementation the user can do is: @Bean
public ClientRegistrationRepository clientRegistrationRepository() {
// Obtain registrations from Hazelcast's `IMap`
final Map<String, ClientRegistration> registrations = getRegistrations();
return registrationId -> registrations.get(registrationId);
} OR @Bean
public ClientRegistrationRepository clientRegistrationRepository() {
// Obtain registrations from Hazelcast's `IMap`
final Map<String, ClientRegistration> registrations = getRegistrations();
return new MapClientRegistrationRepository(getRegistrations());
}
private class MapClientRegistrationRepository implements ClientRegistrationRepository, Iterable<ClientRegistration> {
private Map<String, ClientRegistration> registrations;
private MapClientRegistrationRepository(Map<String, ClientRegistration> registrations) {
this.registrations = registrations;
}
@Override
public ClientRegistration findByRegistrationId(String registrationId) {
return this.registrations.get(registrationId);
}
@Override
public Iterator<ClientRegistration> iterator() {
return this.registrations.values().iterator();
}
} Do you think both of these alternative implementations are straight forward? |
The issue is that this is not dynamic. The values in Hazelcast may be updated after this initialization is done. Also it may be too large to fit in memory. I think it makes sense for the deprecation as migration is straight forward. |
The sample provided was only to demonstrate how easy it is to create a Either way, I still feel deprecating If we were to deprecate, than what do we do with |
I think we would deprecate on an as needed (requested) basis from users. |
@vpavic I spoke to @rwinch and we decided to not deprecate at this time. If we were to go that route than we would need to deprecate We did agree that The PR looks good. I'll get this merged shortly. |
Thanks for the follow up and sorry for my lack activity on this over the past week or so - I was just about to follow up myself.
That's good to hear - hopefully at some later point in the |
Thanks for the PR @vpavic. This is now in master. |
This would allow to back
InMemoryClientRegistrationRepository
with a distributedMap
, such as Hazelcast'sIMap
for instance.Ideally, the implementations should be renamed as well in order to reflect their nature (e.g. to
MapClientRegistrationRepository
). In that case, to ensure backwards compatibility theInMemoryClientRegistrationRepository
that would be provided as an implementation that simply delegates toMapClientRegistrationRepository
and is marked as deprecated. Let me know what's your opinion on this, and if accepted should I do it via this PR or another one later on.