Skip to content

Commit

Permalink
ndb_redis: Added REDIS-Cluster support [BETA]
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbock committed Apr 4, 2017
1 parent 960b761 commit 6d87794
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 24 deletions.
9 changes: 9 additions & 0 deletions src/modules/ndb_redis/doc/ndb_redis.xml
Expand Up @@ -33,6 +33,11 @@
<surname>Isaksen</surname>
<email>misak@uni-tel.dk</email>
</author>
<author>
<firstname>Carsten</firstname>
<surname>Bock</surname>
<email>carsten@ng-voice.com</email>
</author>
</authorgroup>
<copyright>
<year>2011</year>
Expand All @@ -42,6 +47,10 @@
<year>2012</year>
<holder>www.systemonenoc.com</holder>
</copyright>
<copyright>
<year>2017</year>
<holder>ng-voice GmbH</holder>
</copyright>
</bookinfo>
<toc></toc>

Expand Down
19 changes: 19 additions & 0 deletions src/modules/ndb_redis/doc/ndb_redis_admin.xml
Expand Up @@ -148,6 +148,25 @@ modparam("ndb_redis", "connect_timeout", 500)
<programlisting format="linespecific">
...
modparam("ndb_redis", "cmd_timeout", 500)
...
</programlisting>
</example>
</section>
<section id="ndb_redis.p.cluster">
<title><varname>cluster</varname> (integer)</title>
<para>
If set to 1, the module will connect to servers indicated in the "MOVED" reply.
</para>
<para>
<emphasis>
Default value is <quote>0</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>cluster</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("ndb_redis", "cluster", 1)
...
</programlisting>
</example>
Expand Down
20 changes: 19 additions & 1 deletion src/modules/ndb_redis/ndb_redis_mod.c
Expand Up @@ -4,6 +4,9 @@
* Copyright (C) 2012 Vicente Hernando Ara (System One: www.systemonenoc.com)
* - for: redis array reply support
*
* Copyright (C) 2017 Carsten Bock (ng-voice GmbH)
* - for: Cluster support
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -44,6 +47,7 @@ int redis_srv_param(modparam_t type, void *val);
int init_without_redis = 0;
int redis_connect_timeout_param = 1000;
int redis_cmd_timeout_param = 1000;
int redis_cluster_param = 0;

static int w_redis_cmd3(struct sip_msg* msg, char* ssrv, char* scmd,
char* sres);
Expand All @@ -57,6 +61,7 @@ static int fixup_redis_cmd6(void** param, int param_no);

static int w_redis_free_reply(struct sip_msg* msg, char* res);

static int mod_init(void);
static void mod_destroy(void);
static int child_init(int rank);

Expand Down Expand Up @@ -96,6 +101,7 @@ static param_export_t params[]={
{"init_without_redis", INT_PARAM, &init_without_redis},
{"connect_timeout", INT_PARAM, &redis_connect_timeout_param},
{"cmd_timeout", INT_PARAM, &redis_cmd_timeout_param},
{"cluster", INT_PARAM, &redis_cluster_param},
{0, 0, 0}
};

Expand All @@ -108,7 +114,7 @@ struct module_exports exports = {
0, /* exported MI functions */
mod_pvs, /* exported pseudo-variables */
0, /* extra processes */
0, /* module initialization function */
mod_init, /* module initialization function */
0, /* response function */
mod_destroy, /* destroy function */
child_init /* per child init function */
Expand All @@ -130,6 +136,18 @@ static int child_init(int rank)
return 0;
}

/**
*
*/
static int mod_init(void)
{
if (init_list() < 0) {
LM_ERR("failed to initialize redis connections\n");
return -1;
}
return 0;
}

/**
*
*/
Expand Down

0 comments on commit 6d87794

Please sign in to comment.