Skip to content

Remove APIs for separate init and connect of async cluster contexts#165

Merged
bjosv merged 7 commits intovalkey-io:mainfrom
bjosv:embed-context-in-async-context
Feb 7, 2025
Merged

Remove APIs for separate init and connect of async cluster contexts#165
bjosv merged 7 commits intovalkey-io:mainfrom
bjosv:embed-context-in-async-context

Conversation

@bjosv
Copy link
Collaborator

@bjosv bjosv commented Feb 3, 2025

Embed a valkeyClusterContext in a created valkeyClusterAsyncContext to be able to cast between these types. This enables users to access the async context in an event callback without using privdata, and we can remove the APIs previously kept just for this scenario:

valkeyClusterAsyncContext *valkeyClusterAsyncContextInit(const valkeyClusterOptions *options);
int valkeyClusterAsyncConnect(valkeyClusterAsyncContext *acc);
int valkeyClusterAsyncSetEventCallback(valkeyClusterAsyncContext *acc,
                                       void(fn)(const valkeyClusterContext *cc,
                                                int event, void *privdata),

Also removing the testcase based on clusterclient_reconnect_async.c since it was using the removed APIs.

There is now a symmetry to how standalone contexts works, i.e. valkeyAsyncContext embeds the valkeyContext.

Reallocate and embed the valkeyClusterContext in the created valkeyClusterAsyncContext
to be able to cast between these types. This enables users to access the async context
in an event callback without using privdata, and we can remove the APIs previously
kept just for this scenario:

valkeyClusterAsyncContext *valkeyClusterAsyncContextInit(const valkeyClusterOptions *options);
int valkeyClusterAsyncConnect(valkeyClusterAsyncContext *acc);
int valkeyClusterAsyncSetEventCallback(valkeyClusterAsyncContext *acc,
                                       void(fn)(const valkeyClusterContext *cc,
                                                int event, void *privdata),

Remove testcase using clusterclient_reconnect_async.c since it was using the removed APIs.

Signed-off-by: Björn Svensson <[email protected]>
@bjosv bjosv changed the title Remove APIs for separate init and connect of cluster contexts Remove APIs for separate init and connect of async cluster contexts Feb 3, 2025
@bjosv bjosv requested a review from zuiderkwast February 3, 2025 17:38
Copy link
Collaborator

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

+154 −393 is great diff statistics!

@bjosv
Copy link
Collaborator Author

bjosv commented Feb 7, 2025

+154 −393 is great diff statistics!

Oh, lovely, some early spring cleaning.

@bjosv bjosv merged commit 6415305 into valkey-io:main Feb 7, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants