Nordix / hiredis-cluster

C client library for Valkey/Redis Cluster. This project is used and sponsored by Ericsson. It is a fork of the now unmaintained hiredis-vip.
BSD 3-Clause "New" or "Revised" License
86 stars 42 forks source link

Add non-const connect callback #205

Closed bjosv closed 5 months ago

bjosv commented 5 months ago

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.