The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
pipeline.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19/**
20 * $Id: a893b69b249cb13d09629bb86b4d8d2925db5318 $
21 * @file lib/redis/pipeline.h
22 * @brief Redis asynchronous command pipelining
23 *
24 * @copyright 2019 The FreeRADIUS server project
25 * @copyright 2019 Network RADIUS SAS (legal@networkradius.com)
26 *
27 * @author Arran Cudbard-Bell (a.cudbardb@freeradius.org)
28 */
29RCSIDH(redis_pipeline_h, "$Id: a893b69b249cb13d09629bb86b4d8d2925db5318 $")
30
31#include <freeradius-devel/server/connection.h>
32#include <freeradius-devel/server/request.h>
33#include <freeradius-devel/server/trunk.h>
34#include <freeradius-devel/redis/io.h>
35#include <hiredis/async.h>
36
37#include "base.h"
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43typedef enum {
44 FR_REDIS_PIPELINE_OK = 0, //!< No failure.
45 FR_REDIS_PIPELINE_BAD_CMDS, //!< Malformed command set.
46 FR_REDIS_PIPELINE_DST_UNAVAILABLE, //!< Cluster or host is down.
47 FR_REDIS_PIPELINE_TOO_MANY_REDIRECTS, //!< Redirected too many times.
48 FR_REDIS_PIPELINE_FAIL //!< Generic failure.
50
54
55typedef void(*fr_redis_trunk_active_t)(fr_redis_trunk_t *rtrunk, void *uctx);
56
57/** Process the reply from a single command
58 *
59 */
60typedef void (*fr_redis_command_complete_t)(request_t *request, fr_redis_command_t *cmd, redisReply *reply, void *rctx);
61
62/** Do something meaningful with the replies to the commands previously issued
63 *
64 */
65typedef void (*fr_redis_command_set_complete_t)(request_t *request, fr_dlist_head_t *completed, void *rctx);
66
67/** Write a failure result to the rctx so that the module is aware that the request failed
68 *
69 */
70typedef void (*fr_redis_command_set_fail_t)(request_t *request, fr_dlist_head_t *completed, void *rctx);
71
73 fr_redis_command_complete_t complete, void *rctx);
74
76 char const **argv, size_t *argv_len,
77 fr_redis_command_complete_t complete, void *rctx);
78
80 size_t cmd_len,
81 fr_redis_command_complete_t complete, void *rctx);
82
84
85/*
86 * TEMPORARY
87 */
89
91
93 request_t *request,
96 void *rctx, bool autofree);
97
99
101
103
105
107 fr_redis_io_conf_t const *conf, fr_pair_list_t *trigger_args,
109 bool active_oneshot);
110
111#ifdef __cplusplus
112}
113#endif
#define RCSIDH(h, id)
Definition build.h:561
Thread local state for a cluster.
TALLOC_CTX * autofree
Definition common.c:29
Head of a doubly linked list.
Definition dlist.h:51
void * active_uctx
Uctx to pass to active callback.
Definition pipeline.c:168
fr_redis_trunk_active_t active
Callback to run when the trunk becomes active.
Definition pipeline.c:167
fr_redis_ct_t * rtcluster
Cluster this trunk belongs to.
Definition pipeline.c:165
Represents a single command.
Definition pipeline.c:62
Represents a collection of pipelined commands.
Definition pipeline.c:94
fr_redis_trunk_t * fr_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.
Definition pipeline.c:941
char const * fr_redis_command_get_cmd(fr_redis_command_t *cmd)
Definition pipeline.c:975
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 pipeline.h:65
fr_redis_async_rcode_t fr_redis_command_set_rcode(fr_redis_command_set_t *cmds)
Extract the rcode from a command set.
Definition pipeline.c:990
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.
Definition pipeline.c:479
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 pipeline.h:60
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.
Definition pipeline.c:532
int fr_redis_command_set_reset(fr_redis_command_set_t *cmds)
Reset a command set to it's state before enqueuing.
Definition pipeline.c:1008
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.
Definition pipeline.c:249
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 pipeline.c:997
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 pipeline.h:70
fr_redis_pipeline_status_t
Definition pipeline.h:43
@ FR_REDIS_PIPELINE_OK
No failure.
Definition pipeline.h:44
@ FR_REDIS_PIPELINE_TOO_MANY_REDIRECTS
Redirected too many times.
Definition pipeline.h:47
@ FR_REDIS_PIPELINE_BAD_CMDS
Malformed command set.
Definition pipeline.h:45
@ FR_REDIS_PIPELINE_DST_UNAVAILABLE
Cluster or host is down.
Definition pipeline.h:46
@ FR_REDIS_PIPELINE_FAIL
Generic failure.
Definition pipeline.h:48
void fr_redis_command_set_cancel(fr_redis_command_set_t *cmds)
Cancel a command set.
Definition pipeline.c:557
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.
Definition pipeline.c:436
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.
Definition pipeline.c:401
int fr_redis_command_set_clear(fr_redis_command_set_t *cmds)
Definition pipeline.c:1032
void(* fr_redis_trunk_active_t)(fr_redis_trunk_t *rtrunk, void *uctx)
Definition pipeline.h:55
static rs_t * conf
Definition radsniff.c:52
fr_redis_async_rcode_t
Definition base.h:80
Master include file to access all functions and structures in the library.