Skip to content
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 non-const connect callback #205

Merged
merged 10 commits into from
Mar 18, 2024
Merged

Conversation

bjosv
Copy link
Collaborator

@bjosv bjosv commented Mar 15, 2024

If hiredis >= v1.1.0 is used an alternative connect callback can be registered using:

int redisClusterAsyncSetConnectCallbackNC(redisClusterAsyncContext *acc,
                                          redisConnectCallbackNC *fn);

The callback function should have the following prototype, aliased to redisConnectCallbackNC:
void(redisAsyncContext *ac, int status);

The connect callback will be passed a non-const redisAsyncContext* on invocation which
e.g. allows the callback to set a push callback.

The build will check if the used hiredis version supports it, but the new API can also manually be disabled in a build via:
CFLAGS=-DHIRCLUSTER_NO_NONCONST_CONNECT_CB

Note: Not available on Windows. The file hiredis_cluster.def would need to include redisClusterAsyncSetConnectCallbackNC only when hiredis >= v1.1.0 and this requires special handling.

If `hiredis` >= v1.1.0 is used an alternative connect callback can be
registered using:

int redisClusterAsyncSetConnectCallbackNC(redisClusterAsyncContext *acc,
                                          redisConnectCallbackNC *fn);

The callback function should have following prototype, aliased to redisConnectCallbackNC:
   void(redisAsyncContext *ac, int status);

The connect callback will be passed a non-const `redisAsyncContext*` on invocation
which e.g. allows the callback to set a push callback.

The build will check if the used hiredis version supports it,
but the new API can manually be disabled in a build via:
CFLAGS=-DHIRCLUSTER_NO_NONCONST_CONNECT_CB
@bjosv bjosv requested a review from zuiderkwast March 15, 2024 14:54
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.

Good. Just some comments on the docs.

README.md Outdated Show resolved Hide resolved
bjosv and others added 2 commits March 15, 2024 16:19
hircluster.h Outdated Show resolved Hide resolved
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.

Great. I think the example program is good enough now.

examples/src/clientside_caching_async.c Outdated Show resolved Hide resolved
@bjosv bjosv merged commit 07f6da1 into Nordix:master Mar 18, 2024
32 checks passed
@bjosv bjosv deleted the nonconst-connect-cb branch March 18, 2024 11:54
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