Skip to content

Commit

Permalink
Update redisReply to serverReply
Browse files Browse the repository at this point in the history
  • Loading branch information
hwware committed Apr 5, 2024
1 parent 47444c6 commit e8dc18f
Show file tree
Hide file tree
Showing 25 changed files with 293 additions and 293 deletions.
2 changes: 1 addition & 1 deletion deps/hiredis/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ _Note: There were no changes to code between v1.0.0-rc1 and v1.0.0 so see v1.0.
### 0.14.0 (2018-09-25)
**BREAKING CHANGES**:

* Change `redisReply.len` to `size_t`, as it denotes the the size of a string
* Change `serverReply.len` to `size_t`, as it denotes the the size of a string

User code should compare this to `size_t` values as well.
If it was used to compare to other values, casting might be necessary or can be removed, if casting was applied before.
Expand Down
20 changes: 10 additions & 10 deletions deps/hiredis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Bulk and multi-bulk lengths less than -1 or greater than `LLONG_MAX` are now
protocol errors. This is consistent with the RESP specification. On 32-bit
platforms, the upper bound is lowered to `SIZE_MAX`.

Change `redisReply.len` to `size_t`, as it denotes the the size of a string
Change `serverReply.len` to `size_t`, as it denotes the the size of a string

User code should compare this to `size_t` values as well. If it was used to
compare to other values, casting might be necessary or can be removed, if
Expand Down Expand Up @@ -206,8 +206,8 @@ the `err` field in the context will be set (see section on **Errors**).
Once an error is returned the context cannot be reused and you should set up
a new connection.

The standard replies that `redisCommand` are of the type `redisReply`. The
`type` field in the `redisReply` should be used to test what kind of reply
The standard replies that `redisCommand` are of the type `serverReply`. The
`type` field in the `serverReply` should be used to test what kind of reply
was received:

### RESP2
Expand All @@ -232,7 +232,7 @@ was received:

* **`REDIS_REPLY_ARRAY`**:
* A multi bulk reply. The number of elements in the multi bulk reply is stored in
`reply->elements`. Every element in the multi bulk reply is a `redisReply` object as well
`reply->elements`. Every element in the multi bulk reply is a `serverReply` object as well
and can be accessed via `reply->element[..index..]`.
Redis may reply with nested arrays but this is fully supported.

Expand Down Expand Up @@ -266,7 +266,7 @@ Hiredis also supports every new `RESP3` data type which are as follows. For mor

* **`REDIS_REPLY_BIGNUM`**:
* A string representing an arbitrarily large signed or unsigned integer value.
The number will be encoded as a string in the `str` member of `redisReply`.
The number will be encoded as a string in the `str` member of `serverReply`.

* **`REDIS_REPLY_VERB`**:
* A verbatim string, intended to be presented to the user without modification.
Expand Down Expand Up @@ -339,7 +339,7 @@ the `err` field in the context can be used to find out what the cause of this er
The following examples shows a simple pipeline (resulting in only a single call to `write(2)` and
a single call to `read(2)`):
```c
redisReply *reply;
serverReply *reply;
redisAppendCommand(context,"SET foo bar");
redisAppendCommand(context,"GET foo");
redisGetReply(context,(void**)&reply); // reply for SET
Expand Down Expand Up @@ -583,11 +583,11 @@ multi bulk nesting level is higher than this, the parser returns an error.

### Customizing replies

The function `redisReaderGetReply` creates `redisReply` and makes the function
argument `reply` point to the created `redisReply` variable. For instance, if
the response of type `REDIS_REPLY_STATUS` then the `str` field of `redisReply`
The function `redisReaderGetReply` creates `serverReply` and makes the function
argument `reply` point to the created `serverReply` variable. For instance, if
the response of type `REDIS_REPLY_STATUS` then the `str` field of `serverReply`
will hold the status as a vanilla C string. However, the functions that are
responsible for creating instances of the `redisReply` can be customized by
responsible for creating instances of the `serverReply` can be customized by
setting the `fn` field on the `redisReader` struct. This should be done
immediately after creating the `redisReader`.

Expand Down
12 changes: 6 additions & 6 deletions deps/hiredis/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static int __redisShiftCallback(redisCallbackList *list, redisCallback *target)
return REDIS_ERR;
}

static void __redisRunCallback(redisAsyncContext *ac, redisCallback *cb, redisReply *reply) {
static void __redisRunCallback(redisAsyncContext *ac, redisCallback *cb, serverReply *reply) {
redisContext *c = &(ac->c);
if (cb->fn != NULL) {
c->flags |= REDIS_IN_CALLBACK;
Expand All @@ -313,7 +313,7 @@ static void __redisRunCallback(redisAsyncContext *ac, redisCallback *cb, redisRe
}
}

static void __redisRunPushCallback(redisAsyncContext *ac, redisReply *reply) {
static void __redisRunPushCallback(redisAsyncContext *ac, serverReply *reply) {
if (ac->push_cb != NULL) {
ac->c.flags |= REDIS_IN_CALLBACK;
ac->push_cb(ac, reply);
Expand Down Expand Up @@ -467,7 +467,7 @@ void redisAsyncDisconnect(redisAsyncContext *ac) {
__redisAsyncDisconnect(ac);
}

static int __redisGetSubscribeCallback(redisAsyncContext *ac, redisReply *reply, redisCallback *dstcb) {
static int __redisGetSubscribeCallback(redisAsyncContext *ac, serverReply *reply, redisCallback *dstcb) {
redisContext *c = &(ac->c);
dict *callbacks;
redisCallback *cb = NULL;
Expand Down Expand Up @@ -546,7 +546,7 @@ static int __redisGetSubscribeCallback(redisAsyncContext *ac, redisReply *reply,
#define redisIsSpontaneousPushReply(r) \
(redisIsPushReply(r) && !redisIsSubscribeReply(r))

static int redisIsSubscribeReply(redisReply *reply) {
static int redisIsSubscribeReply(serverReply *reply) {
char *str;
size_t len, off;

Expand Down Expand Up @@ -618,9 +618,9 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
* In this case we also want to close the connection, and have the
* user wait until the server is ready to take our request.
*/
if (((redisReply*)reply)->type == REDIS_REPLY_ERROR) {
if (((serverReply*)reply)->type == REDIS_REPLY_ERROR) {
c->err = REDIS_ERR_OTHER;
snprintf(c->errstr,sizeof(c->errstr),"%s",((redisReply*)reply)->str);
snprintf(c->errstr,sizeof(c->errstr),"%s",((serverReply*)reply)->str);
c->reader->fn->freeObject(reply);
__redisAsyncDisconnect(ac);
return;
Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
static aeEventLoop *loop;

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-glib.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ command_cb(redisAsyncContext *ac,
gpointer r,
gpointer user_data G_GNUC_UNUSED)
{
redisReply *reply = r;
serverReply *reply = r;

if (reply) {
g_print("REPLY: %s\n", reply->str);
Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-ivykis.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <adapters/ivykis.h>

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-libev.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <adapters/libev.h>

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-libevent-ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <adapters/libevent.h>

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-libevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <adapters/libevent.h>

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
if (c->errstr) {
printf("errstr: %s\n", c->errstr);
Expand Down
4 changes: 2 additions & 2 deletions deps/hiredis/examples/example-libhv.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <adapters/libhv.h>

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand All @@ -18,7 +18,7 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) {

void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
(void)privdata;
redisReply *reply = r;
serverReply *reply = r;

if (reply == NULL) {
printf("`DEBUG SLEEP` error: %s\n", c->errstr ? c->errstr : "unknown error");
Expand Down
4 changes: 2 additions & 2 deletions deps/hiredis/examples/example-libsdevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
(void)privdata;
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
/* The DEBUG SLEEP command will almost always fail, because we have set a 1 second timeout */
printf("`DEBUG SLEEP` error: %s\n", c->errstr ? c->errstr : "unknown error");
Expand All @@ -20,7 +20,7 @@ void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
}

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
printf("`GET key` error: %s\n", c->errstr ? c->errstr : "unknown error");
return;
Expand Down
4 changes: 2 additions & 2 deletions deps/hiredis/examples/example-libuv.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
(void)privdata; //unused
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
/* The DEBUG SLEEP command will almost always fail, because we have set a 1 second timeout */
printf("`DEBUG SLEEP` error: %s\n", c->errstr ? c->errstr : "unknown error");
Expand All @@ -20,7 +20,7 @@ void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
}

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
printf("`GET key` error: %s\n", c->errstr ? c->errstr : "unknown error");
return;
Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-macosx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <adapters/macosx.h>

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
static int exit_loop = 0;

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);

Expand Down
8 changes: 4 additions & 4 deletions deps/hiredis/examples/example-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
exit(-1); \
} while (0)

static void assertReplyAndFree(redisContext *context, redisReply *reply, int type) {
static void assertReplyAndFree(redisContext *context, serverReply *reply, int type) {
if (reply == NULL)
panicAbort("NULL reply from server (error: %s)", context->errstr);

Expand All @@ -56,7 +56,7 @@ static void assertReplyAndFree(redisContext *context, redisReply *reply, int typ

/* Switch to the RESP3 protocol and enable client tracking */
static void enableClientTracking(redisContext *c) {
redisReply *reply = redisCommand(c, "HELLO 3");
serverReply *reply = redisCommand(c, "HELLO 3");
if (reply == NULL || c->err) {
panicAbort("NULL reply or server error (error: %s)", c->errstr);
}
Expand All @@ -76,7 +76,7 @@ static void enableClientTracking(redisContext *c) {
}

void pushReplyHandler(void *privdata, void *r) {
redisReply *reply = r;
serverReply *reply = r;
int *invalidations = privdata;

/* Sanity check on the invalidation reply */
Expand Down Expand Up @@ -106,7 +106,7 @@ void privdata_dtor(void *privdata) {
int main(int argc, char **argv) {
unsigned int j, invalidations = 0;
redisContext *c;
redisReply *reply;
serverReply *reply;

const char *hostname = (argc > 1) ? argv[1] : "127.0.0.1";
int port = (argc > 2) ? atoi(argv[2]) : 6379;
Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace std;

void getCallback(redisAsyncContext *, void * r, void * privdata) {

redisReply * reply = static_cast<redisReply *>(r);
serverReply * reply = static_cast<serverReply *>(r);
ExampleQt * ex = static_cast<ExampleQt *>(privdata);
if (reply == nullptr || ex == nullptr) return;

Expand Down
4 changes: 2 additions & 2 deletions deps/hiredis/examples/example-redismoduleapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
(void)privdata; //unused
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
/* The DEBUG SLEEP command will almost always fail, because we have set a 1 second timeout */
printf("`DEBUG SLEEP` error: %s\n", c->errstr ? c->errstr : "unknown error");
Expand All @@ -20,7 +20,7 @@ void debugCallback(redisAsyncContext *c, void *r, void *privdata) {
}

void getCallback(redisAsyncContext *c, void *r, void *privdata) {
redisReply *reply = r;
serverReply *reply = r;
if (reply == NULL) {
if (c->errstr) {
printf("errstr: %s\n", c->errstr);
Expand Down
2 changes: 1 addition & 1 deletion deps/hiredis/examples/example-ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char **argv) {
redisSSLContext *ssl;
redisSSLContextError ssl_error = REDIS_SSL_CTX_NONE;
redisContext *c;
redisReply *reply;
serverReply *reply;
if (argc < 4) {
printf("Usage: %s <host> <port> <cert> <key> [ca]\n", argv[0]);
exit(1);
Expand Down
4 changes: 2 additions & 2 deletions deps/hiredis/examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static void example_argv_command(redisContext *c, size_t n) {
char **argv, tmp[42];
size_t *argvlen;
redisReply *reply;
serverReply *reply;

/* We're allocating two additional elements for command and key */
argv = malloc(sizeof(*argv) * (2 + n));
Expand Down Expand Up @@ -58,7 +58,7 @@ static void example_argv_command(redisContext *c, size_t n) {
int main(int argc, char **argv) {
unsigned int j, isunix = 0;
redisContext *c;
redisReply *reply;
serverReply *reply;
const char *hostname = (argc > 1) ? argv[1] : "127.0.0.1";

if (argc > 2) {
Expand Down
Loading

0 comments on commit e8dc18f

Please sign in to comment.