State machine for Redis cluster coordinator thread.
More...
#include <freeradius-devel/redis/attrs.h>
#include <freeradius-devel/redis/base.h>
#include <freeradius-devel/redis/cluster_async.h>
#include <freeradius-devel/io/coord_pair.h>
#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/server/process.h>
Go to the source code of this file.
|
| static int | _process_redis_cluster_free (process_redis_cluster_t *cluster) |
| |
| static fr_cmp_ret_t | cluster_id_cmp (void const *a, void const *b) |
| |
| static fr_cmp_ret_t | cluster_server_cmp (void const *a, void const *b) |
| |
| static int | fr_redis_cluster_shards_nodes_to_pairs (redisReply *reply, fr_pair_t *shard_vp) |
| | Convert the "nodes" array in CLUSTER SHARDS replies into pairs.
|
| |
| static int | fr_redis_cluster_shards_slots_to_pairs (redisReply *reply, fr_pair_t *shard_vp, bool slots_covered[KEY_SLOTS]) |
| | Convert the "slots" array in CLUSTER SHARDS replies into pairs.
|
| |
| static int | fr_redis_cluster_shards_to_pairs (TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *list, redisReply *reply) |
| | Convert the reply to CLUSTER SHARDS into pairs.
|
| |
| static int | fr_redis_cluster_slots_to_pairs (TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *list, redisReply *reply) |
| | Convert the reply to CLUSER SLOTS into pairs.
|
| |
| static int | mod_instantiate (module_inst_ctx_t const *mctx) |
| |
| static int | mod_load (void) |
| |
| static unlang_action_t | mod_process (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| |
| static int | mod_thread_instantiate (module_thread_inst_ctx_t const *mctx) |
| |
| static int | process_redis_cluster_node_add (TALLOC_CTX *ctx, process_redis_cluster_t *cluster, process_redis_t const *inst, fr_redis_conf_t *conf, fr_pair_t *host_vp, fr_pair_t *port_vp) |
| |
| static void | process_redis_pending_cancel (module_ctx_t const *mctx, request_t *request, UNUSED fr_signal_t action) |
| |
| static fr_cmp_ret_t | process_redis_pending_cmp (void const *a, void const *b) |
| |
| static unlang_action_t | process_redis_return_existing (request_t *request, process_redis_cluster_t *cluster, uint32_t worker_id) |
| |
| static unlang_action_t | process_redis_return_failed (request_t *request, process_redis_cluster_t *cluster, uint32_t worker_id) |
| | Send a Cluster-Failed message to a worker.
|
| |
| | RECV (cluster_map_bootstrap) |
| |
| | RECV (cluster_map_get) |
| |
| static void | redis_cluster_info_results (request_t *request, UNUSED fr_redis_command_t *cmd, redisReply *reply, void *rctx) |
| |
| static void | redis_cluster_info_server_results (request_t *request, UNUSED fr_redis_command_t *cmd, redisReply *reply, void *rctx) |
| |
| static unlang_action_t | redis_cluster_map_get (UNUSED unlang_result_t *p_result, request_t *request, void *uctx) |
| |
| static void | redis_cluster_map_get_cancel (request_t *request, UNUSED fr_signal_t action, void *uctx) |
| |
| static void | redis_cluster_map_get_refetch (UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx) |
| |
| static unlang_action_t | redis_cluster_map_get_resume (UNUSED unlang_result_t *p_result, request_t *request, void *uctx) |
| |
| static void | redis_cluster_map_get_timeout (UNUSED fr_timer_list_t *el, UNUSED fr_time_t now, void *uctx) |
| |
| static void | redis_cluster_slots_results (request_t *request, UNUSED fr_redis_command_t *cmd, redisReply *reply, void *rctx) |
| |
State machine for Redis cluster coordinator thread.
- Id
- 13a53235e534252f784c11e6043d0b637256bab7
- Copyright
- 2026 Network RADIUS SAS (legal.nosp@m.@net.nosp@m.workr.nosp@m.adiu.nosp@m.s.com)
Definition in file base.c.
◆ process_redis_cluster_t
| struct process_redis_cluster_t |
Coordinator representation of a Redis cluster.
Definition at line 75 of file base.c.
| Data Fields |
|
fr_ipaddr_t |
addr |
IP address of the first bootstrap server. |
|
fr_rb_node_t |
cluster_by_id |
Entry in the tree of clusters by ID. |
|
fr_rb_node_t |
cluster_by_server |
Entry in the tree of clusters by bootstrap server. |
|
uint16_t |
cluster_id |
Numeric ID assigned by the coordinator. |
|
fr_pair_list_t |
cluster_pairs |
Pairs built from the last fetch. |
|
fr_redis_conf_t * |
conf |
Redis config for this cluster. |
|
fr_coord_pair_t * |
coord_pair |
The coord_pair which requested this cluster map. |
|
fr_timer_t * |
ev |
Timer event for retry / refresh. |
|
bool |
failed |
Has the cluster failed. |
|
bool |
fetching |
The map is being fetched. |
|
fr_time_t |
last_update |
When was the map last updated. |
|
fr_dlist_head_t |
nodes |
List of current nodes in the cluster. |
|
fr_rb_tree_t |
pending |
Requests waiting for custer map update. |
|
uint16_t |
port |
Port of the first bootstrap server. |
|
fr_redis_ct_t * |
rtcluster |
Cluster used to allocate redis trunk connections. |
◆ process_redis_node_rctx_t
| struct process_redis_node_rctx_t |
Resume context for node specific calls.
Definition at line 163 of file base.c.
◆ process_redis_node_t
| struct process_redis_node_t |
Individual cluster node.
Definition at line 63 of file base.c.
| Data Fields |
|
uint64_t |
current_epoch |
Redis cluster epoch as reported by this node. |
|
fr_dlist_t |
entry |
Entry in the list of cluster nodes. |
|
bool |
in_cluster |
Has the node been found in the latest cluster map. |
|
fr_redis_io_conf_t |
io_conf |
Connection config for this node. |
|
fr_pair_list_t |
trigger_args |
Pair list to pass to trigger. |
|
fr_redis_trunk_t * |
trunk |
Trunk connection for this node. |
|
uint32_t |
version |
Redis version on this node. |
◆ process_redis_pending_t
| struct process_redis_pending_t |
◆ process_redis_rctx_t
| struct process_redis_rctx_t |
Resume context for Redis requests.
Definition at line 174 of file base.c.
◆ process_redis_sections_t
| struct process_redis_sections_t |
◆ process_redis_t
◆ process_redis_thread_t
| struct process_redis_thread_t |
◆ FR_REDIS_PACKET_CODE_VALID
◆ FR_REDIS_PROCESS_CODE_VALID
◆ PROCESS_CODE_DO_NOT_RESPOND
◆ PROCESS_CODE_MAX
◆ PROCESS_INST
◆ PROCESS_PACKET_CODE_VALID
◆ PROCESS_PACKET_TYPE
◆ PROCESS_RCTX
◆ map_get_status_t
State of cluster map fetching from each node.
| Enumerator |
|---|
| CLUSTER_MAP_GET_INFO | |
| CLUSTER_MAP_GOT_INFO | |
| CLUSTER_MAP_GET_MAP | |
| CLUSTER_MAP_GOT_MAP | |
| CLUSTER_MAP_GET_FAILED | |
| CLUSTER_MAP_GET_TIMEOUT | |
Definition at line 152 of file base.c.
◆ _process_redis_cluster_free()
◆ cluster_id_cmp()
| static fr_cmp_ret_t cluster_id_cmp |
( |
void const * |
a, |
|
|
void const * |
b |
|
) |
| |
|
static |
◆ cluster_server_cmp()
| static fr_cmp_ret_t cluster_server_cmp |
( |
void const * |
a, |
|
|
void const * |
b |
|
) |
| |
|
static |
◆ fr_redis_cluster_shards_nodes_to_pairs()
| static int fr_redis_cluster_shards_nodes_to_pairs |
( |
redisReply * |
reply, |
|
|
fr_pair_t * |
shard_vp |
|
) |
| |
|
static |
Convert the "nodes" array in CLUSTER SHARDS replies into pairs.
- Parameters
-
| reply | Redis reply containing the "nodes" array. |
| shard_vp | Pair representing shard to build ndoes pairs under. |
- Returns
- number of nodes found
- -1 on error
Definition at line 251 of file base.c.
◆ fr_redis_cluster_shards_slots_to_pairs()
| static int fr_redis_cluster_shards_slots_to_pairs |
( |
redisReply * |
reply, |
|
|
fr_pair_t * |
shard_vp, |
|
|
bool |
slots_covered[KEY_SLOTS] |
|
) |
| |
|
static |
Convert the "slots" array in CLUSTER SHARDS replies into pairs.
- Parameters
-
| reply | Redis reply containing the "slots" array. |
| shard_vp | Pair representing shard to build slots pairs under. |
| slots_covered | Array recording which slots have been covered. |
- Returns
- number of slot ranges found
- -1 on error
Definition at line 206 of file base.c.
◆ fr_redis_cluster_shards_to_pairs()
| static int fr_redis_cluster_shards_to_pairs |
( |
TALLOC_CTX * |
ctx, |
|
|
request_t * |
request, |
|
|
fr_pair_list_t * |
list, |
|
|
redisReply * |
reply |
|
) |
| |
|
static |
Convert the reply to CLUSTER SHARDS into pairs.
The CLUSTER SHARDS reply is designed as an extensible structure using arrays containing named fields. i.e. an element which is the field name, followed by the value in the next element.
The fields for node entries are specifically described as being extensible.
The CLUSTER SHARDS reply structure
[0] -> Shard 0
[0] -> "slots"
[1] -> Array of slot entries in pairs of start / end values.
[0] -> key_slot0_start
[1] -> key_slot0_end
[2] -> key_slot1_start
[3] -> key_slot1_end
[4 .. n] -> key_slot2_start .. key_slotm_end
[2] -> "nodes"
[3] -> Array of nodes which cover the slots in the "slots" array.
[0] -> Node 0
[0] -> "id"
[1] -> Node ID
[2] -> "port"
[3] -> (integer) port number
[4] -> "ip"
[5] -> IP address of node
[6] -> "endpoint"
[7] -> Preferred endpoint to connect to node
[8] -> "role"
[9] -> ("master"|"replica")
[10] -> "replication-offset"
[11] -> (integer) replication offset
[12] -> "health"
[13] -> ("online"|"failed"|"loading")
[1] -> Node 1
[0 .. n] -> Entries for Node 1
[1] -> Shard 1
[...]
Definition at line 357 of file base.c.
◆ fr_redis_cluster_slots_to_pairs()
| static int fr_redis_cluster_slots_to_pairs |
( |
TALLOC_CTX * |
ctx, |
|
|
request_t * |
request, |
|
|
fr_pair_list_t * |
list, |
|
|
redisReply * |
reply |
|
) |
| |
|
static |
Convert the reply to CLUSER SLOTS into pairs.
The CLUSTER SLOTS reply structure
[0] -> key slot range 0
[0] -> key_slot_start
[1] -> key_slot_end
[2] -> master_node
[0] -> master 0 ip (string)
[1] -> master 0 port (number)
[3..n] -> replica_node(s)
[1] -> key slot range 1)
[0] -> key_slot_start
[1] -> key_slot_end
[2] -> master_node
[0] -> master 1 ip (string)
[1] -> master 1 port (number)
[3..n] -> replica_node(s)
[n] -> key slot range n
[0] -> key_slot_start
[1] -> key_slot_end
[2] -> master_node
[0] -> master n ip (string)
[1] -> master n port (number)
[3..n] -> replica_node(s)
- Parameters
-
| [in] | ctx | to allocate pairs in. |
| [in,out] | list | to populate with pairs. |
| [in] | reply | from CLUSTER SLOTS |
Definition at line 450 of file base.c.
◆ mod_instantiate()
◆ mod_load()
| static int mod_load |
( |
void |
| ) |
|
|
static |
◆ mod_process()
◆ mod_thread_instantiate()
◆ process_redis_cluster_node_add()
◆ process_redis_pending_cancel()
◆ process_redis_pending_cmp()
| static fr_cmp_ret_t process_redis_pending_cmp |
( |
void const * |
a, |
|
|
void const * |
b |
|
) |
| |
|
static |
◆ process_redis_return_existing()
◆ process_redis_return_failed()
Send a Cluster-Failed message to a worker.
Definition at line 692 of file base.c.
◆ RECV() [1/2]
| RECV |
( |
cluster_map_bootstrap |
| ) |
|
◆ RECV() [2/2]
◆ redis_cluster_info_results()
◆ redis_cluster_info_server_results()
◆ redis_cluster_map_get()
◆ redis_cluster_map_get_cancel()
◆ redis_cluster_map_get_refetch()
◆ redis_cluster_map_get_resume()
◆ redis_cluster_map_get_timeout()
◆ redis_cluster_slots_results()
◆ attr_packet_type
◆ attr_worker_id
◆ cluster_id
◆ config
Initial value:= {
}
#define CONF_PARSER_TERMINATOR
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
conf_parser_t const trunk_config[]
Config parser definitions to populate a trunk_conf_t.
Definition at line 142 of file base.c.
◆ dict_freeradius
◆ process_redis
Initial value:= {
.common = {
.name = "redis",
},
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
fr_dict_attr_t const * attr_redis_packet_type
fr_dict_t const * dict_redis
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
static int mod_load(void)
static int mod_instantiate(module_inst_ctx_t const *mctx)
static const conf_parser_t config[]
Resume context for Redis requests.
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
#define MODULE_THREAD_INST(_ctype)
#define MODULE_RCTX(_ctype)
#define MODULE_INST(_ctype)
Definition at line 1236 of file base.c.
◆ process_redis_dict
Initial value:= {
}
#define DICT_AUTOLOAD_TERMINATOR
static fr_dict_t const * dict_freeradius
Definition at line 39 of file base.c.
◆ process_redis_dict_attr
Initial value:= {
}
@ FR_TYPE_INT32
32 Bit signed integer.
static fr_dict_attr_t const * attr_worker_id
Definition at line 48 of file base.c.
◆ process_state
| fr_process_state_t const process_state[] |
|
static |
Initial value:= {
.recv = recv_cluster_map_bootstrap,
},
.recv = recv_cluster_map_get,
}
}
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ FR_REDIS_CLUSTER_MAP_BOOTSTRAP
@ FR_REDIS_CLUSTER_MAP_GET
@ FR_REDIS_CLUSTER_MAP_UPDATE
Definition at line 1222 of file base.c.
◆ redis_shards_version