hazelcast / hazelcast-nodejs-client

Hazelcast Node.js Client
https://hazelcast.com/clients/node-js/
Apache License 2.0
150 stars 59 forks source link

[TRACKING ISSUE] Enabled ClientStateListener to be used on FailoverClient #976

Closed hz-devops-test closed 3 years ago

hz-devops-test commented 3 years ago

The tracking issue for the Java side PR.

See https://github.com/hazelcast/hazelcast/pull/19090 for details.


Due to nature of how failover client works, we don't allow different listeners to be registered at different client configs.

Since ClientStateListener registers itself to the ClientConfig, this prevents it to be used via FailoverClient.

The reasoning behind constructor register itself is to force the user to use this via config rather than registering it after client starts.

So, sticking with the same decision we introduce another constructor which accepts ClientFailoverConfig and registers same listener(itself) to all the client configs.

Also on the ClientStateListener I have ignored CLIENT_CHANGED_CLUSTER. This is rather a temporal event. We fire CLIENT_CONNECTED than CLIENT_CHANGED_CLUSTER, in those cases we want the current state to remain CLIENT_CONNECTED.

Fixes https://github.com/hazelcast/hazelcast/issues/18351

EE PR: #NNNN (link to enterprise counterpart PR)

Checklist:

srknzl commented 3 years ago

This issue does not exist on the Node.js client since lifecycleListeners are plain functions and they can be passed to different client configs.see https://github.com/hazelcast/hazelcast-nodejs-client/blob/061c096a88568d8b99e798259376ce673e5a8b03/test/unit/config/FailoverConfigBuilderTest.js#L242