Skip to content

Commit

Permalink
Format libvalkeycluster code after renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosv committed Jun 19, 2024
1 parent f38dc71 commit 6ce9fef
Show file tree
Hide file tree
Showing 32 changed files with 351 additions and 309 deletions.
2 changes: 1 addition & 1 deletion libvalkeycluster/adapters/ae.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int valkeyAeAttach_link(valkeyAsyncContext *ac, void *base) {
}

static int valkeyClusterAeAttach(aeEventLoop *loop,
valkeyClusterAsyncContext *acc) {
valkeyClusterAsyncContext *acc) {

if (acc == NULL || loop == NULL) {
return VALKEY_ERR;
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/adapters/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int valkeyGlibAttach_link(valkeyAsyncContext *ac, void *adapter) {
}

static int valkeyClusterGlibAttach(valkeyClusterAsyncContext *acc,
valkeyClusterGlibAdapter *adapter) {
valkeyClusterGlibAdapter *adapter) {
if (acc == NULL || adapter == NULL) {
return VALKEY_ERR;
}
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/adapters/libev.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int valkeyLibevAttach_link(valkeyAsyncContext *ac, void *loop) {
}

static int valkeyClusterLibevAttach(valkeyClusterAsyncContext *acc,
struct ev_loop *loop) {
struct ev_loop *loop) {
if (loop == NULL || acc == NULL) {
return VALKEY_ERR;
}
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/adapters/libevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int valkeyLibeventAttach_link(valkeyAsyncContext *ac, void *base) {
}

static int valkeyClusterLibeventAttach(valkeyClusterAsyncContext *acc,
struct event_base *base) {
struct event_base *base) {

if (acc == NULL || base == NULL) {
return VALKEY_ERR;
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/adapters/libuv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int valkeyLibuvAttach_link(valkeyAsyncContext *ac, void *loop) {
}

static int valkeyClusterLibuvAttach(valkeyClusterAsyncContext *acc,
uv_loop_t *loop) {
uv_loop_t *loop) {

if (acc == NULL || loop == NULL) {
return VALKEY_ERR;
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/adlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <valkey/alloc.h>
#include <stdlib.h>
#include <valkey/alloc.h>

#include "adlist.h"
#include "vkutil.h"
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
*/

#include <assert.h>
#include <valkey/alloc.h>
#include <limits.h>
#include <stdlib.h>
#include <valkey/alloc.h>

#include "dict.h"

Expand Down
5 changes: 3 additions & 2 deletions libvalkeycluster/examples/src/example.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <valkeycluster/valkeycluster.h>
#include <stdio.h>
#include <stdlib.h>
#include <valkeycluster/valkeycluster.h>

int main(int argc, char **argv) {
UNUSED(argc);
Expand All @@ -23,7 +23,8 @@ int main(int argc, char **argv) {
printf("SET: %s\n", reply->str);
freeReplyObject(reply);

valkeyReply *reply2 = (valkeyReply *)valkeyClusterCommand(cc, "GET %s", "key");
valkeyReply *reply2 =
(valkeyReply *)valkeyClusterCommand(cc, "GET %s", "key");
printf("GET: %s\n", reply2->str);
freeReplyObject(reply2);

Expand Down
12 changes: 6 additions & 6 deletions libvalkeycluster/examples/src/example_async.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <valkeycluster/adapters/libevent.h>
#include <valkeycluster/valkeycluster.h>
#include <stdio.h>
#include <stdlib.h>
#include <valkeycluster/adapters/libevent.h>
#include <valkeycluster/valkeycluster.h>

void getCallback(valkeyClusterAsyncContext *cc, void *r, void *privdata) {
valkeyReply *reply = (valkeyReply *)r;
Expand Down Expand Up @@ -60,25 +60,25 @@ int main(int argc, char **argv) {

int status;
status = valkeyClusterAsyncCommand(cc, setCallback, (char *)"THE_ID",
"SET %s %s", "key", "value");
"SET %s %s", "key", "value");
if (status != VALKEY_OK) {
printf("error: err=%d errstr=%s\n", cc->err, cc->errstr);
}

status = valkeyClusterAsyncCommand(cc, getCallback, (char *)"THE_ID",
"GET %s", "key");
"GET %s", "key");
if (status != VALKEY_OK) {
printf("error: err=%d errstr=%s\n", cc->err, cc->errstr);
}

status = valkeyClusterAsyncCommand(cc, setCallback, (char *)"THE_ID",
"SET %s %s", "key2", "value2");
"SET %s %s", "key2", "value2");
if (status != VALKEY_OK) {
printf("error: err=%d errstr=%s\n", cc->err, cc->errstr);
}

status = valkeyClusterAsyncCommand(cc, getCallback, (char *)"THE_ID",
"GET %s", "key2");
"GET %s", "key2");
if (status != VALKEY_OK) {
printf("error: err=%d errstr=%s\n", cc->err, cc->errstr);
}
Expand Down
9 changes: 5 additions & 4 deletions libvalkeycluster/examples/src/example_tls.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <valkey/valkey.h>
#include <valkey/valkey_ssl.h>
#include <valkeycluster/valkeycluster.h>
#include <valkeycluster/valkeycluster_ssl.h>
#include <stdio.h>
#include <stdlib.h>

#define CLUSTER_NODE_TLS "127.0.0.1:7301"

Expand All @@ -16,7 +16,7 @@ int main(int argc, char **argv) {

valkeyInitOpenSSL();
ssl = valkeyCreateSSLContext("ca.crt", NULL, "client.crt", "client.key",
NULL, &ssl_error);
NULL, &ssl_error);
if (!ssl) {
printf("SSL Context error: %s\n", valkeySSLContextGetError(ssl_error));
exit(1);
Expand Down Expand Up @@ -46,7 +46,8 @@ int main(int argc, char **argv) {
printf("SET: %s\n", reply->str);
freeReplyObject(reply);

valkeyReply *reply2 = (valkeyReply *)valkeyClusterCommand(cc, "GET %s", "key");
valkeyReply *reply2 =
(valkeyReply *)valkeyClusterCommand(cc, "GET %s", "key");
if (!reply2) {
printf("Reply missing: %s\n", cc->errstr);
exit(-1);
Expand Down
4 changes: 2 additions & 2 deletions libvalkeycluster/tests/clusterclient_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*/

#include "adapters/libevent.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -83,7 +83,7 @@ void replyCallback(valkeyClusterAsyncContext *acc, void *r, void *privdata) {
if (resend_failed_cmd) {
printf("resend '%s'\n", cmd_history[cmd_id]);
if (valkeyClusterAsyncCommand(acc, replyCallback, (void *)cmd_id,
cmd_history[cmd_id]) != VALKEY_OK)
cmd_history[cmd_id]) != VALKEY_OK)
printf("send error\n");
return;
}
Expand Down
7 changes: 4 additions & 3 deletions libvalkeycluster/tests/clusterclient_reconnect_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/

#include "adapters/libevent.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -29,7 +29,8 @@ void connectToValkey(valkeyClusterAsyncContext *acc) {
int status = valkeyClusterConnect2(acc->cc);
if (status == VALKEY_OK) {
// cluster mode
} else if (acc->cc->err && strcmp(acc->cc->errstr, VALKEY_ENOCLUSTER) == 0) {
} else if (acc->cc->err &&
strcmp(acc->cc->errstr, VALKEY_ENOCLUSTER) == 0) {
printf("[no cluster]\n");
acc->cc->err = 0;
memset(acc->cc->errstr, '\0', strlen(acc->cc->errstr));
Expand Down Expand Up @@ -81,7 +82,7 @@ void sendNextCommand(int fd, short kind, void *arg) {

// coverity[tainted_scalar]
int status = valkeyClusterAsyncCommandToNode(acc, node, replyCallback,
NULL, command);
NULL, command);
ASSERT_MSG(status == VALKEY_OK, acc->errstr);
} else {
// disconnect if nothing is left to read from stdin
Expand Down
10 changes: 5 additions & 5 deletions libvalkeycluster/tests/ct_async.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "adapters/libevent.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -48,20 +48,20 @@ void eventCallback(const valkeyClusterContext *cc, int event, void *privdata) {
if (event == VALKEYCLUSTER_EVENT_READY) {
int status;
status = valkeyClusterAsyncCommand(acc, setCallback, (char *)"ID",
"SET key12345 value");
"SET key12345 value");
ASSERT_MSG(status == VALKEY_OK, acc->errstr);

/* This command will trigger a disconnect in its reply callback. */
status = valkeyClusterAsyncCommand(acc, getCallback, (char *)"ID",
"GET key12345");
"GET key12345");
ASSERT_MSG(status == VALKEY_OK, acc->errstr);

status = valkeyClusterAsyncCommand(acc, setCallback, (char *)"ID",
"SET key23456 value2");
"SET key23456 value2");
ASSERT_MSG(status == VALKEY_OK, acc->errstr);

status = valkeyClusterAsyncCommand(acc, getCallback, (char *)"ID",
"GET key23456");
"GET key23456");
ASSERT_MSG(status == VALKEY_OK, acc->errstr);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/tests/ct_async_glib.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "adapters/glib.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include <assert.h>

#define CLUSTER_NODE "127.0.0.1:7000"
Expand Down
4 changes: 2 additions & 2 deletions libvalkeycluster/tests/ct_async_libev.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "adapters/libev.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include <assert.h>

#define CLUSTER_NODE "127.0.0.1:7000"
Expand Down Expand Up @@ -47,7 +47,7 @@ int main(int argc, char **argv) {
valkeyClusterAsyncSetDisconnectCallback(acc, disconnectCallback);

status = valkeyClusterAsyncCommand(acc, setCallback, (char *)"ID",
"SET key value");
"SET key value");
ASSERT_MSG(status == VALKEY_OK, acc->errstr);

status =
Expand Down
4 changes: 2 additions & 2 deletions libvalkeycluster/tests/ct_async_libuv.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "adapters/libuv.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include <assert.h>

#define CLUSTER_NODE "127.0.0.1:7000"
Expand Down Expand Up @@ -48,7 +48,7 @@ int main(int argc, char **argv) {
valkeyClusterAsyncSetDisconnectCallback(acc, disconnectCallback);

status = valkeyClusterAsyncCommand(acc, setCallback, (char *)"ID",
"SET key value");
"SET key value");
ASSERT_MSG(status == VALKEY_OK, acc->errstr);

status =
Expand Down
20 changes: 12 additions & 8 deletions libvalkeycluster/tests/ct_commands.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include "win32.h"
#include <assert.h>
#include <stdio.h>
Expand All @@ -26,7 +26,8 @@ void test_exists(valkeyClusterContext *cc) {
CHECK_REPLY_OK(cc, reply);
freeReplyObject(reply);

reply = (valkeyReply *)valkeyClusterCommand(cc, "EXISTS key1 key2 nosuchkey");
reply =
(valkeyReply *)valkeyClusterCommand(cc, "EXISTS key1 key2 nosuchkey");
CHECK_REPLY_INT(cc, reply, 2);
freeReplyObject(reply);
}
Expand Down Expand Up @@ -118,8 +119,8 @@ void test_hset_hget_hdel_hexists(valkeyClusterContext *cc) {
freeReplyObject(reply);

// Set second hash field
reply =
(valkeyReply *)valkeyClusterCommand(cc, "HSET myhash field3 hsetvalue3");
reply = (valkeyReply *)valkeyClusterCommand(
cc, "HSET myhash field3 hsetvalue3");
CHECK_REPLY_INT(cc, reply, 1); // Set 1 field
freeReplyObject(reply);

Expand Down Expand Up @@ -179,7 +180,7 @@ void test_eval(valkeyClusterContext *cc) {

// Single key, string response
reply = (valkeyReply *)valkeyClusterCommand(cc, "eval %s 1 %s",
"return KEYS[1]", "key1");
"return KEYS[1]", "key1");
CHECK_REPLY_STR(cc, reply, "key1");
freeReplyObject(reply);

Expand Down Expand Up @@ -328,12 +329,14 @@ void test_xgroup(valkeyClusterContext *cc) {
CHECK_REPLY_TYPE(r, VALKEY_REPLY_INTEGER);
freeReplyObject(r);

r = valkeyClusterCommand(cc, "XGROUP CREATE mystream consumer-group-name 0");
r = valkeyClusterCommand(cc,
"XGROUP CREATE mystream consumer-group-name 0");
CHECK_REPLY_OK(cc, r);
freeReplyObject(r);

/* Attempting to create an already existing group gives error */
r = valkeyClusterCommand(cc, "XGROUP CREATE mystream consumer-group-name 0");
r = valkeyClusterCommand(cc,
"XGROUP CREATE mystream consumer-group-name 0");
CHECK_REPLY_ERROR(cc, r, "BUSYGROUP");
freeReplyObject(r);

Expand Down Expand Up @@ -382,7 +385,8 @@ void test_xinfo(valkeyClusterContext *cc) {
CHECK_REPLY_TYPE(r, VALKEY_REPLY_ARRAY);
freeReplyObject(r);

r = valkeyClusterCommand(cc, "XINFO CONSUMERS mystream consumer-group-name");
r = valkeyClusterCommand(cc,
"XINFO CONSUMERS mystream consumer-group-name");
CHECK_REPLY_TYPE(r, VALKEY_REPLY_ARRAY);
freeReplyObject(r);
}
Expand Down
4 changes: 2 additions & 2 deletions libvalkeycluster/tests/ct_connection.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "adapters/libevent.h"
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"

#include <assert.h>
#include <stdbool.h>
Expand Down Expand Up @@ -588,7 +588,7 @@ void test_async_command_timeout(void) {
ExpectedResult r = {
.noreply = true, .errstr = "Timeout", .disconnect = true};
status = valkeyClusterAsyncCommandToNode(acc, node, commandCallback, &r,
"DEBUG SLEEP 0.2");
"DEBUG SLEEP 0.2");
assert(status == VALKEY_OK);

event_base_dispatch(base);
Expand Down
2 changes: 1 addition & 1 deletion libvalkeycluster/tests/ct_connection_ipv6.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "valkeycluster.h"
#include "test_utils.h"
#include "valkeycluster.h"
#include "win32.h"
#include <assert.h>
#include <stdio.h>
Expand Down
Loading

0 comments on commit 6ce9fef

Please sign in to comment.