diff options
Diffstat (limited to 'async.h')
-rw-r--r-- | async.h | 100 |
1 files changed, 50 insertions, 50 deletions
@@ -11,48 +11,48 @@ * */ -#ifndef __HIREDIS_ASYNC_H -#define __HIREDIS_ASYNC_H +#ifndef __HIREDICT_ASYNC_H +#define __HIREDICT_ASYNC_H #include "hiredict.h" #ifdef __cplusplus extern "C" { #endif -struct redisAsyncContext; /* need forward declaration of redisAsyncContext */ +struct redictAsyncContext; /* need forward declaration of redictAsyncContext */ struct dict; /* dictionary header is included in async.c */ /* Reply callback prototype and container */ -typedef void (redisCallbackFn)(struct redisAsyncContext*, void*, void*); -typedef struct redisCallback { - struct redisCallback *next; /* simple singly linked list */ - redisCallbackFn *fn; +typedef void (redictCallbackFn)(struct redictAsyncContext*, void*, void*); +typedef struct redictCallback { + struct redictCallback *next; /* simple singly linked list */ + redictCallbackFn *fn; int pending_subs; int unsubscribe_sent; void *privdata; -} redisCallback; +} redictCallback; /* List of callbacks for either regular replies or pub/sub */ -typedef struct redisCallbackList { - redisCallback *head, *tail; -} redisCallbackList; +typedef struct redictCallbackList { + redictCallback *head, *tail; +} redictCallbackList; /* Connection callback prototypes */ -typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status); -typedef void (redisConnectCallback)(const struct redisAsyncContext*, int status); -typedef void (redisConnectCallbackNC)(struct redisAsyncContext *, int status); -typedef void(redisTimerCallback)(void *timer, void *privdata); +typedef void (redictDisconnectCallback)(const struct redictAsyncContext*, int status); +typedef void (redictConnectCallback)(const struct redictAsyncContext*, int status); +typedef void (redictConnectCallbackNC)(struct redictAsyncContext*, int status); +typedef void (redictTimerCallback)(void *timer, void *privdata); -/* Context for an async connection to Redis */ -typedef struct redisAsyncContext { +/* Context for an async connection to Redict */ +typedef struct redictAsyncContext { /* Hold the regular context, so it can be realloc'ed. */ - redisContext c; + redictContext c; /* Setup error flags so they can be used directly. */ int err; char *errstr; - /* Not used by hiredis */ + /* Not used by hiredict */ void *data; void (*dataCleanup)(void *privdata); @@ -71,15 +71,15 @@ typedef struct redisAsyncContext { } ev; /* Called when either the connection is terminated due to an error or per - * user request. The status is set accordingly (REDIS_OK, REDIS_ERR). */ - redisDisconnectCallback *onDisconnect; + * user request. The status is set accordingly (REDICT_OK, REDICT_ERR). */ + redictDisconnectCallback *onDisconnect; /* Called when the first write event was received. */ - redisConnectCallback *onConnect; - redisConnectCallbackNC *onConnectNC; + redictConnectCallback *onConnect; + redictConnectCallbackNC *onConnectNC; /* Regular command callbacks */ - redisCallbackList replies; + redictCallbackList replies; /* Address used for connect() */ struct sockaddr *saddr; @@ -87,45 +87,45 @@ typedef struct redisAsyncContext { /* Subscription callbacks */ struct { - redisCallbackList replies; + redictCallbackList replies; struct dict *channels; struct dict *patterns; int pending_unsubs; } sub; /* Any configured RESP3 PUSH handler */ - redisAsyncPushFn *push_cb; -} redisAsyncContext; - -/* Functions that proxy to hiredis */ -redisAsyncContext *redisAsyncConnectWithOptions(const redisOptions *options); -redisAsyncContext *redisAsyncConnect(const char *ip, int port); -redisAsyncContext *redisAsyncConnectBind(const char *ip, int port, const char *source_addr); -redisAsyncContext *redisAsyncConnectBindWithReuse(const char *ip, int port, + redictAsyncPushFn *push_cb; +} redictAsyncContext; + +/* Functions that proxy to hiredict */ +redictAsyncContext *redictAsyncConnectWithOptions(const redictOptions *options); +redictAsyncContext *redictAsyncConnect(const char *ip, int port); +redictAsyncContext *redictAsyncConnectBind(const char *ip, int port, const char *source_addr); +redictAsyncContext *redictAsyncConnectBindWithReuse(const char *ip, int port, const char *source_addr); -redisAsyncContext *redisAsyncConnectUnix(const char *path); -int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn); -int redisAsyncSetConnectCallbackNC(redisAsyncContext *ac, redisConnectCallbackNC *fn); -int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn); +redictAsyncContext *redictAsyncConnectUnix(const char *path); +int redictAsyncSetConnectCallback(redictAsyncContext *ac, redictConnectCallback *fn); +int redictAsyncSetConnectCallbackNC(redictAsyncContext *ac, redictConnectCallbackNC *fn); +int redictAsyncSetDisconnectCallback(redictAsyncContext *ac, redictDisconnectCallback *fn); -redisAsyncPushFn *redisAsyncSetPushCallback(redisAsyncContext *ac, redisAsyncPushFn *fn); -int redisAsyncSetTimeout(redisAsyncContext *ac, struct timeval tv); -void redisAsyncDisconnect(redisAsyncContext *ac); -void redisAsyncFree(redisAsyncContext *ac); +redictAsyncPushFn *redictAsyncSetPushCallback(redictAsyncContext *ac, redictAsyncPushFn *fn); +int redictAsyncSetTimeout(redictAsyncContext *ac, struct timeval tv); +void redictAsyncDisconnect(redictAsyncContext *ac); +void redictAsyncFree(redictAsyncContext *ac); /* Handle read/write events */ -void redisAsyncHandleRead(redisAsyncContext *ac); -void redisAsyncHandleWrite(redisAsyncContext *ac); -void redisAsyncHandleTimeout(redisAsyncContext *ac); -void redisAsyncRead(redisAsyncContext *ac); -void redisAsyncWrite(redisAsyncContext *ac); +void redictAsyncHandleRead(redictAsyncContext *ac); +void redictAsyncHandleWrite(redictAsyncContext *ac); +void redictAsyncHandleTimeout(redictAsyncContext *ac); +void redictAsyncRead(redictAsyncContext *ac); +void redictAsyncWrite(redictAsyncContext *ac); /* Command functions for an async context. Write the command to the * output buffer and register the provided callback. */ -int redisvAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, va_list ap); -int redisAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, ...); -int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen); -int redisAsyncFormattedCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *cmd, size_t len); +int redictvAsyncCommand(redictAsyncContext *ac, redictCallbackFn *fn, void *privdata, const char *format, va_list ap); +int redictAsyncCommand(redictAsyncContext *ac, redictCallbackFn *fn, void *privdata, const char *format, ...); +int redictAsyncCommandArgv(redictAsyncContext *ac, redictCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen); +int redictAsyncFormattedCommand(redictAsyncContext *ac, redictCallbackFn *fn, void *privdata, const char *cmd, size_t len); #ifdef __cplusplus } |