The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Typedefs | Enumerations | Functions
pipeline.h File Reference

Redis asynchronous command pipelining. More...

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

Go to the source code of this file.

Typedefs

typedef void(* fr_redis_command_complete_t) (request_t *request, fr_redis_command_t *cmd, redisReply *reply, void *rctx)
 Process the reply from a single command.
 
typedef void(* fr_redis_command_set_complete_t) (request_t *request, fr_dlist_head_t *completed, void *rctx)
 Do something meaningful with the replies to the commands previously issued.
 
typedef void(* fr_redis_command_set_fail_t) (request_t *request, fr_dlist_head_t *completed, void *rctx)
 Write a failure result to the rctx so that the module is aware that the request failed.
 
typedef struct fr_redis_command_set_s fr_redis_command_set_t
 
typedef struct fr_redis_command_s fr_redis_command_t
 
typedef void(* fr_redis_trunk_active_t) (fr_redis_trunk_t *rtrunk, void *uctx)
 
typedef struct fr_redis_trunk_s fr_redis_trunk_t
 

Enumerations

enum  fr_redis_pipeline_status_t {
  FR_REDIS_PIPELINE_OK = 0 ,
  FR_REDIS_PIPELINE_BAD_CMDS ,
  FR_REDIS_PIPELINE_DST_UNAVAILABLE ,
  FR_REDIS_PIPELINE_TOO_MANY_REDIRECTS ,
  FR_REDIS_PIPELINE_FAIL
}
 

Functions

fr_redis_pipeline_status_t fr_redis_command_argv_add (fr_redis_command_set_t *cmds, size_t argc, char const **argv, size_t *argv_len, fr_redis_command_complete_t complete, void *rctx)
 Add a command with arguments to the command set.
 
char const * fr_redis_command_get_cmd (fr_redis_command_t *cmd)
 
fr_redis_pipeline_status_t fr_redis_command_literal_add (fr_redis_command_set_t *cmds, char const *cmd_str, fr_redis_command_complete_t complete, void *rctx)
 Add a literal command to the command set.
 
fr_redis_pipeline_status_t fr_redis_command_preformatted_add (fr_redis_command_set_t *cmds, char const *cmd_str, size_t cmd_len, fr_redis_command_complete_t complete, void *rctx)
 Add an preformatted command to the command set as formatted by redisCommandFormat or it's variants.
 
fr_redis_command_set_tfr_redis_command_set_alloc (TALLOC_CTX *ctx, request_t *request, fr_redis_command_set_complete_t complete, fr_redis_command_set_fail_t fail, void *rctx, bool autofree)
 Allocate a new command set.
 
void fr_redis_command_set_cancel (fr_redis_command_set_t *cmds)
 Cancel a command set.
 
int fr_redis_command_set_clear (fr_redis_command_set_t *cmds)
 Reinitialise a command set so that it can be used again.
 
void fr_redis_command_set_next_node (fr_redis_command_set_t *cmds, fr_redis_io_conf_t *ioconf)
 Extract the next node address and port from a command set.
 
fr_redis_async_rcode_t fr_redis_command_set_rcode (fr_redis_command_set_t *cmds)
 Extract the rcode from a command set.
 
void fr_redis_command_set_rcode_set (fr_redis_command_set_t *cmds, fr_redis_async_rcode_t rcode)
 Set the rcode for a command set.
 
int fr_redis_command_set_reset (fr_redis_command_set_t *cmds)
 Reset a command set to it's state before enqueuing.
 
fr_redis_trunk_tfr_redis_trunk_alloc (fr_redis_ct_t *rtcluster, fr_redis_io_conf_t const *conf, fr_pair_list_t *trigger_args, fr_redis_trunk_active_t active, void *active_uctx, bool active_oneshot)
 Allocate a new trunk.
 
fr_redis_pipeline_status_t redis_command_set_enqueue (fr_redis_trunk_t *rtrunk, fr_redis_command_set_t *cmds)
 Enqueue a command set on a specific trunk.
 

Detailed Description

Redis asynchronous command pipelining.

Id
a62873c78656ee5b8129cf584c9a4b9a0536a396
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 pipeline.h.

Typedef Documentation

◆ fr_redis_command_complete_t

typedef void(* fr_redis_command_complete_t) (request_t *request, fr_redis_command_t *cmd, redisReply *reply, void *rctx)

Process the reply from a single command.

Definition at line 60 of file pipeline.h.

◆ fr_redis_command_set_complete_t

typedef void(* fr_redis_command_set_complete_t) (request_t *request, fr_dlist_head_t *completed, void *rctx)

Do something meaningful with the replies to the commands previously issued.

Definition at line 65 of file pipeline.h.

◆ fr_redis_command_set_fail_t

typedef void(* fr_redis_command_set_fail_t) (request_t *request, fr_dlist_head_t *completed, void *rctx)

Write a failure result to the rctx so that the module is aware that the request failed.

Definition at line 70 of file pipeline.h.

◆ fr_redis_command_set_t

Definition at line 52 of file pipeline.h.

◆ fr_redis_command_t

Definition at line 51 of file pipeline.h.

◆ fr_redis_trunk_active_t

typedef void(* fr_redis_trunk_active_t) (fr_redis_trunk_t *rtrunk, void *uctx)

Definition at line 55 of file pipeline.h.

◆ fr_redis_trunk_t

Definition at line 53 of file pipeline.h.

Enumeration Type Documentation

◆ fr_redis_pipeline_status_t

Enumerator
FR_REDIS_PIPELINE_OK 

No failure.

FR_REDIS_PIPELINE_BAD_CMDS 

Malformed command set.

FR_REDIS_PIPELINE_DST_UNAVAILABLE 

Cluster or host is down.

FR_REDIS_PIPELINE_TOO_MANY_REDIRECTS 

Redirected too many times.

FR_REDIS_PIPELINE_FAIL 

Generic failure.

Definition at line 43 of file pipeline.h.

Function Documentation

◆ fr_redis_command_argv_add()

fr_redis_pipeline_status_t fr_redis_command_argv_add ( fr_redis_command_set_t cmds,
size_t  argc,
char const **  argv,
size_t argv_len,
fr_redis_command_complete_t  complete,
void *  rctx 
)

Add a command with arguments to the command set.

The command and arguments must either be entirely static, or parented by the command set.

Parameters
[in]cmdsCommand set to add command to.
[in]argcNumber of arguments.
[in]argvRedis command arguments.
[in]argv_lenLength of the command arguments.
[in]completeCallback to run when this command completes
[in]rctxto pass to complete
Returns
  • FR_REDIS_PIPELINE_BAD_CMDS if a bad command sequence is enqueued.
  • FR_REDIS_PIPELINE_OK if command was enqueued successfully.

Definition at line 439 of file pipeline.c.

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

◆ fr_redis_command_get_cmd()

char const * fr_redis_command_get_cmd ( fr_redis_command_t cmd)

Definition at line 1025 of file pipeline.c.

+ Here is the caller graph for this function:

◆ fr_redis_command_literal_add()

fr_redis_pipeline_status_t fr_redis_command_literal_add ( fr_redis_command_set_t cmds,
char const *  cmd_str,
fr_redis_command_complete_t  complete,
void *  rctx 
)

Add a literal command to the command set.

The command must either be entirely static, or parented by the command set.

Note
Caller should disallow "SUBSCRIBE" et al, if they're not appropriate. As subscribing to a stream where we're not expecting it would break things, badly.
Parameters
[in]cmdsCommand set to add command to.
[in]cmd_strA fully expanded/formatted command to send to redis. Must be static, or have the same lifetime as the command set (allocated with the command set as the parent).
[in]completeCallback to run when this command completes
[in]rctxto pass to complete
Returns
  • FR_REDIS_PIPELINE_BAD_CMDS if a bad command sequence is enqueued.
  • FR_REDIS_PIPELINE_OK if command was enqueued successfully.

Definition at line 404 of file pipeline.c.

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

◆ fr_redis_command_preformatted_add()

fr_redis_pipeline_status_t fr_redis_command_preformatted_add ( fr_redis_command_set_t cmds,
char const *  cmd_str,
size_t  cmd_len,
fr_redis_command_complete_t  complete,
void *  rctx 
)

Add an preformatted command to the command set as formatted by redisCommandFormat or it's variants.

The command must either be entirely static, or parented by the command set.

Note
Caller should disallow "SUBSCRIBE" et al, if they're not appropriate. As subscribing to a stream where we're not expecting it would break things, badly.
Parameters
[in]cmdsCommand set to add command to.
[in]cmd_strA fully formatted command to send to redis. Must be static, or have the same lifetime as the command set (allocated with the command set as the parent).
[in]cmd_lenThe length of cmd_str (as returned by redisCommandForamt)
[in]completeCallback to run when this command completes
[in]rctxto pass to complete
Returns
  • FR_REDIS_PIPELINE_BAD_CMDS if a bad command sequence is enqueued.
  • FR_REDIS_PIPELINE_OK if command was enqueued successfully.

Definition at line 482 of file pipeline.c.

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

◆ fr_redis_command_set_alloc()

fr_redis_command_set_t * fr_redis_command_set_alloc ( TALLOC_CTX *  ctx,
request_t request,
fr_redis_command_set_complete_t  complete,
fr_redis_command_set_fail_t  fail,
void *  rctx,
bool  autofree 
)

Allocate a new command set.

This is a set of commands that the calling module wants to execute on the redis server in sequence.

Control will be returned to the caller via the registered complete and fail functions.

Parameters
[in]ctxto bind the command set's lifetime to.
[in]requestto pass to places that need it.
[in]completeFunction to call when all commands have been processed.
[in]failFunction to call if the command set was not executed or was partially executed.
[in]rctxResume context to pass to complete and fail functions.
[in]autofreeShould the command set be freed when completed.
Returns
A new or refurbished command set.

Definition at line 252 of file pipeline.c.

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

◆ fr_redis_command_set_cancel()

void fr_redis_command_set_cancel ( fr_redis_command_set_t cmds)

Cancel a command set.

Parameters
[in]cmdsCommand set to cancel.

Definition at line 566 of file pipeline.c.

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

◆ fr_redis_command_set_clear()

int fr_redis_command_set_clear ( fr_redis_command_set_t cmds)

Reinitialise a command set so that it can be used again.

Frees the completed commands, and returns the command set to the state it was in when it was created via fr_redis_command_set_alloc(). The command set keeps the request, the resume ctx, the callbacks, and the autofree setting it was allocated with, so that the caller can add a new set of commands and enqueue the command set again.

Note
The caller must have finished reading the results before calling this function. The completed commands are freed here, as is the address of the node named by a MOVED / ASK reply. fr_redis_command_set_rcode() reports success after this function returns, whatever the previous execution did.
Parameters
[in]cmdsCommand set to reinitialise.
Returns
  • 0 on success.
  • -1 if the command set is still executing, in which case nothing is changed.

Definition at line 1106 of file pipeline.c.

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

◆ fr_redis_command_set_next_node()

void fr_redis_command_set_next_node ( fr_redis_command_set_t cmds,
fr_redis_io_conf_t ioconf 
)

Extract the next node address and port from a command set.

Definition at line 1054 of file pipeline.c.

+ Here is the caller graph for this function:

◆ fr_redis_command_set_rcode()

fr_redis_async_rcode_t fr_redis_command_set_rcode ( fr_redis_command_set_t cmds)

Extract the rcode from a command set.

Definition at line 1040 of file pipeline.c.

+ Here is the caller graph for this function:

◆ fr_redis_command_set_rcode_set()

void fr_redis_command_set_rcode_set ( fr_redis_command_set_t cmds,
fr_redis_async_rcode_t  rcode 
)

Set the rcode for a command set.

Definition at line 1047 of file pipeline.c.

+ Here is the caller graph for this function:

◆ fr_redis_command_set_reset()

int fr_redis_command_set_reset ( fr_redis_command_set_t cmds)

Reset a command set to it's state before enqueuing.

For use when handling MOVED / ASK where the command set needs to be sent to another node.

Definition at line 1065 of file pipeline.c.

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

◆ fr_redis_trunk_alloc()

fr_redis_trunk_t * fr_redis_trunk_alloc ( fr_redis_ct_t rtcluster,
fr_redis_io_conf_t const *  io_conf,
fr_pair_list_t trigger_args,
fr_redis_trunk_active_t  active,
void *  active_uctx,
bool  active_oneshot 
)

Allocate a new trunk.

Parameters
[in]rtclusterto allocate the trunk for.
[in]io_confDescribing the connection to a single REDIS host.
[in]trigger_argsPairs to pass to trigger requests, if triggers are enabled.
[in]activeCallback to run when the trunk becomes active.
[in]active_uctxUctx to pass to active callback.
[in]active_oneshotShould the call back be run just once.
Returns
  • On success, a new fr_redis_trunk_t which can be used for pipelining commands.
  • NULL on failure.

Definition at line 991 of file pipeline.c.

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

◆ redis_command_set_enqueue()

fr_redis_pipeline_status_t redis_command_set_enqueue ( fr_redis_trunk_t rtrunk,
fr_redis_command_set_t cmds 
)

Enqueue a command set on a specific trunk.

The command set may be passed around several trunks before it is complete. This is to allow it to follow MOVED and ASK responses.

Parameters
[in]rtrunkto enqueue command set on.
[in]cmdsCommand set to enqueue.
Returns
  • FR_REDIS_PIPELINE_OK if commands were immediately enqueued or placed in the backlog.
  • FR_REDIS_PIPELINE_DST_UNAVAILABLE if the REDIS host is unreachable.
  • FR_REDIS_PIPELINE_FAIL any other general error.

Definition at line 535 of file pipeline.c.

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