The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
io.h File Reference

Redis asynchronous I/O connection allocation. More...

#include "config.h"
#include <freeradius-devel/redis/base.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/server/connection.h>
#include <hiredis/async.h>
+ Include dependency graph for io.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_redis_handle_t
 Store I/O state. More...
 
struct  fr_redis_io_conf_t
 
struct  fr_redis_sqn_ignore_t
 

Typedefs

typedef uint64_t fr_redis_sqn_t
 

Functions

connection_tfr_redis_connection_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, connection_conf_t const *conn_conf, fr_redis_io_conf_t const *io_conf, char const *log_prefix)
 Allocate an async redis I/O connection.
 
redisAsyncContext * fr_redis_connection_get_async_ctx (connection_t *conn)
 Return the redisAsyncContext associated with the connection.
 
static void fr_redis_connection_ignore_response (fr_redis_handle_t *h, fr_redis_sqn_t sqn)
 Ignore a response with a specific sequence number.
 
static bool fr_redis_connection_process_response (fr_redis_handle_t *h)
 Update the response sequence number and check if we should ignore the response.
 
static fr_redis_sqn_t fr_redis_connection_sent_request (fr_redis_handle_t *h)
 Tell the handle we sent a command, and get the SQN that command was assigned.
 

Detailed Description

Redis asynchronous I/O connection allocation.

Id
e411f32350816d9b7dffd350a5e0ab951756c87a
Author
Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)

Definition in file io.h.


Data Structure Documentation

◆ fr_redis_handle_t

struct fr_redis_handle_t

Store I/O state.

There are three layers of wrapping structures

connection_t -> fr_redis_handle_t -> redisAsyncContext

Definition at line 75 of file io.h.

+ Collaboration diagram for fr_redis_handle_t:
Data Fields
redisAsyncContext * ac Async handle for hiredis.
fr_event_fd_t * fd_ev IO event.
bool freeing Ensure that redisAsyncFree doesn't cause a callback loop.
fr_dlist_head_t ignore Contains SQNs for responses that should be ignored.
bool read_set We're listening for reads.
fr_redis_sqn_t req_sqn Current redis request number.

Note: It would take 5.8 million years running at 100,000 requests/s to overflow, but my OCD requires that the max uses for trunk connections is set to UINT64_MAX if not specified by the user. It's one branch, and it makes me happy, deal with it.

fr_redis_sqn_t rsp_sqn Current redis response number.
fr_timer_t * timer_ev Connection timer.
bool write_set We're listening for writes.

◆ fr_redis_io_conf_t

struct fr_redis_io_conf_t

Definition at line 50 of file io.h.

Data Fields
uint32_t database number on Redis server.
char const * hostname
char const * log_prefix
char const * password to authenticate to Redis.
uint16_t port
bool use_tls
char const * username to authenticate to Redis.

◆ fr_redis_sqn_ignore_t

struct fr_redis_sqn_ignore_t

Definition at line 63 of file io.h.

+ Collaboration diagram for fr_redis_sqn_ignore_t:
Data Fields
fr_dlist_t entry
fr_redis_sqn_t sqn

Typedef Documentation

◆ fr_redis_sqn_t

typedef uint64_t fr_redis_sqn_t

Definition at line 61 of file io.h.

Function Documentation

◆ fr_redis_connection_alloc()

connection_t * fr_redis_connection_alloc ( TALLOC_CTX *  ctx,
fr_event_list_t el,
connection_conf_t const *  conn_conf,
fr_redis_io_conf_t const *  io_conf,
char const *  log_prefix 
)

Allocate an async redis I/O connection.

Definition at line 610 of file io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_redis_connection_get_async_ctx()

redisAsyncContext * fr_redis_connection_get_async_ctx ( connection_t conn)

Return the redisAsyncContext associated with the connection.

This is needed to issue commands to the redis server.

Parameters
[in]connTo retrieve async ctx from.
Returns
The async ctx.

Definition at line 654 of file io.c.

◆ fr_redis_connection_ignore_response()

static void fr_redis_connection_ignore_response ( fr_redis_handle_t h,
fr_redis_sqn_t  sqn 
)
inlinestatic

Ignore a response with a specific sequence number.

Parameters
[in]hto ignore the response on.
[in]sqnthe command to ignore.

Definition at line 116 of file io.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_redis_connection_process_response()

static bool fr_redis_connection_process_response ( fr_redis_handle_t h)
inlinestatic

Update the response sequence number and check if we should ignore the response.

MUST be called for every reply received using the handle. Relies on the fact that responses from REDIS are FIFO with requests.

Parameters
[in]hto check for ignored responses.

Definition at line 134 of file io.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_redis_connection_sent_request()

static fr_redis_sqn_t fr_redis_connection_sent_request ( fr_redis_handle_t h)
inlinestatic

Tell the handle we sent a command, and get the SQN that command was assigned.

MUST be called for every command sent using the handle. Relies on the fact that responses from REDIS are FIFO with requests.

Parameters
[in]hthe request was sent on.
Returns
the handle specific SQN.

Definition at line 106 of file io.h.

+ Here is the caller graph for this function: