summaryrefslogtreecommitdiff
path: root/hiredis.h
diff options
context:
space:
mode:
Diffstat (limited to 'hiredis.h')
-rw-r--r--hiredis.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/hiredis.h b/hiredis.h
index bf10509..20e9bfa 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -92,6 +92,15 @@ typedef long long ssize_t;
* SO_REUSEADDR is being used. */
#define REDIS_CONNECT_RETRIES 10
+/* Forward declarations for structs defined elsewhere */
+struct redisAsyncContext;
+struct redisContext;
+
+/* RESP3 push helpers and callback prototypes */
+#define redisIsPushReply(r) (((redisReply*)(r))->type == REDIS_REPLY_PUSH)
+typedef void (redisPushFn)(void *, void *);
+typedef void (redisAsyncPushFn)(struct redisAsyncContext *, void *);
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -140,6 +149,9 @@ struct redisSsl;
*/
#define REDIS_OPT_NOAUTOFREE 0x04
+/* Don't automatically intercept and free RESP3 PUSH replies. */
+#define REDIS_OPT_NO_PUSH_AUTOFREE 0x08
+
/* In Unix systems a file descriptor is a regular signed int, with -1
* representing an invalid descriptor. In Windows it is a SOCKET
* (32- or 64-bit unsigned integer depending on the architecture), where
@@ -180,6 +192,10 @@ typedef struct {
* file descriptor */
redisFD fd;
} endpoint;
+
+ /* A user defined PUSH message callback */
+ redisPushFn *push_cb;
+ redisAsyncPushFn *async_push_cb;
} redisOptions;
/**
@@ -194,9 +210,6 @@ typedef struct {
(opts)->type = REDIS_CONN_UNIX; \
(opts)->endpoint.unix_socket = path;
-struct redisAsyncContext;
-struct redisContext;
-
typedef struct redisContextFuncs {
void (*free_privdata)(void *);
void (*async_read)(struct redisAsyncContext *);
@@ -235,6 +248,9 @@ typedef struct redisContext {
/* Additional private data for hiredis addons such as SSL */
void *privdata;
+
+ /* An optional RESP3 PUSH handler */
+ redisPushFn *push_cb;
} redisContext;
redisContext *redisConnectWithOptions(const redisOptions *options);
@@ -261,6 +277,7 @@ redisContext *redisConnectFd(redisFD fd);
*/
int redisReconnect(redisContext *c);
+redisPushFn *redisSetPushCallback(redisContext *c, redisPushFn *fn);
int redisSetTimeout(redisContext *c, const struct timeval tv);
int redisEnableKeepAlive(redisContext *c);
void redisFree(redisContext *c);