The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
pipeline.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 * This program is 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: 1617d651e2b2a411deab2e8426c94c9957913ee9 $
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: 1617d651e2b2a411deab2e8426c94c9957913ee9 $")
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#ifdef __cplusplus
38extern "C" {
39#endif
40
41typedef enum {
42 FR_REDIS_PIPELINE_OK = 0, //!< No failure.
43 FR_REDIS_PIPELINE_BAD_CMDS, //!< Malformed command set.
44 FR_REDIS_PIPELINE_DST_UNAVAILABLE, //!< Cluster or host is down.
45 FR_REDIS_PIPELINE_TOO_MANY_REDIRECTS, //!< Redirected too many times.
46 FR_REDIS_PIPELINE_FAIL //!< Generic failure.
48
53
54/** Do something meaningful with the replies to the commands previously issued
55 *
56 * Should mark the request as runnable, if there's a request.
57 */
58typedef void (*fr_redis_command_set_complete_t)(request_t *request, fr_dlist_head_t *completed, void *rctx);
59
60/** Write a failure result to the rctx so that the module is aware that the request failed
61 *
62 * Should mark the request as runnable, if there's a request.
63 */
64typedef void (*fr_redis_command_set_fail_t)(request_t *request, fr_dlist_head_t *completed, void *rctx);
65
67 char const *cmd_str, size_t cmd_len);
68
69/*
70 * TEMPORARY
71 */
73
75
77 request_t *request,
80 void *rctx);
81
84
86 trunk_conf_t const *tconf);
87
88#ifdef __cplusplus
89}
90#endif
#define RCSIDH(h, id)
Definition build.h:484
Head of a doubly linked list.
Definition dlist.h:51
Stores all information relating to an event list.
Definition event.c:411
Thread local state for a cluster.
Definition pipeline.c:39
Represents a single command.
Definition pipeline.c:67
Represents a collection of pipelined commands.
Definition pipeline.c:87
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:58
fr_redis_cluster_thread_t * fr_redis_cluster_thread_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, trunk_conf_t const *tconf)
Allocate per-thread, per-cluster instance.
Definition pipeline.c:647
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)
Allocate a new command set.
Definition pipeline.c:206
fr_redis_trunk_t * fr_redis_trunk_alloc(fr_redis_cluster_thread_t *rtcluster, fr_redis_io_conf_t const *conf)
Allocate a new trunk.
Definition pipeline.c:615
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:392
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:64
fr_redis_pipeline_status_t
Definition pipeline.h:41
@ FR_REDIS_PIPELINE_OK
No failure.
Definition pipeline.h:42
@ FR_REDIS_PIPELINE_TOO_MANY_REDIRECTS
Redirected too many times.
Definition pipeline.h:45
@ FR_REDIS_PIPELINE_BAD_CMDS
Malformed command set.
Definition pipeline.h:43
@ FR_REDIS_PIPELINE_DST_UNAVAILABLE
Cluster or host is down.
Definition pipeline.h:44
@ FR_REDIS_PIPELINE_FAIL
Generic failure.
Definition pipeline.h:46
fr_redis_pipeline_status_t fr_redis_command_preformatted_add(fr_redis_command_set_t *cmds, char const *cmd_str, size_t cmd_len)
Add a preformatted/expanded command to the command set.
Definition pipeline.c:292
redisReply * fr_redis_command_get_result(fr_redis_command_t *cmd)
Definition pipeline.c:270
static rs_t * conf
Definition radsniff.c:53
Common configuration parameters for a trunk.
Definition trunk.h:224
static fr_event_list_t * el