root/cherokee/trunk/cherokee/balancer.h

Revision 1949, 3.6 kB (checked in by alo, 1 month ago)

--

Line 
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4  *
5  * Authors:
6  *      Alvaro Lopez Ortega <alvaro@alobbs.com>
7  *
8  * Copyright (C) 2001-2008 Alvaro Lopez Ortega
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of version 2 of the GNU General Public
12  * License as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22  * USA
23  */
24
25 #if !defined (CHEROKEE_INSIDE_CHEROKEE_H) && !defined (CHEROKEE_COMPILATION)
26 # error "Only <cherokee/cherokee.h> can be included directly, this file may disappear or change contents."
27 #endif
28
29 #ifndef CHEROKEE_BALANCER_H
30 #define CHEROKEE_BALANCER_H
31
32 #include <cherokee/common.h>
33 #include <cherokee/module.h>
34 #include <cherokee/connection.h>
35 #include <cherokee/source.h>
36
37 CHEROKEE_BEGIN_DECLS
38
39 typedef ret_t (* balancer_dispatch_func_t)  (void *balancer, cherokee_connection_t *conn, cherokee_source_t **src);
40 typedef ret_t (* balancer_configure_func_t) (void *balancer, cherokee_server_t *srv, cherokee_config_node_t *conf);
41
42 typedef struct {
43         cherokee_module_t         module;
44
45         /* Properties */
46         cherokee_source_t       **sources;
47         cuint_t                   sources_len;
48         cuint_t                   sources_size;
49
50         /* Virtual methods */
51         balancer_configure_func_t configure;
52         balancer_dispatch_func_t  dispatch;
53
54 } cherokee_balancer_t;
55
56 #define BAL(b)  ((cherokee_balancer_t *)(b))
57
58
59 typedef ret_t (* balancer_new_func_t)  (cherokee_balancer_t **balancer);
60 typedef ret_t (* balancer_free_func_t) (cherokee_balancer_t  *balancer);
61
62
63 /* Easy initialization
64  */
65 #define BALANCER_CONF_PROTOTYPE(name)                              \
66         ret_t cherokee_balancer_ ## name ## _configure (           \
67                 cherokee_balancer_t    *,                          \
68                 cherokee_server_t      *,                          \
69                 cherokee_config_node_t *)
70
71 #define PLUGIN_INFO_BALANCER_EASY_INIT(name)                       \
72         BALANCER_CONF_PROTOTYPE(name);                             \
73                                                                    \
74         PLUGIN_INFO_INIT(name, cherokee_balancer,                  \
75                 (void *)cherokee_balancer_ ## name ## _new,        \
76                 (void *)cherokee_balancer_ ## name ## _configure)
77
78 #define PLUGIN_INFO_BALANCER_EASIEST_INIT(name)                    \
79         PLUGIN_EMPTY_INIT_FUNCTION(name)                           \
80         PLUGIN_INFO_BALANCER_EASY_INIT(name)
81
82
83 /* Balancer methods
84  */
85 ret_t cherokee_balancer_init_base      (cherokee_balancer_t *balancer, cherokee_plugin_info_t *info);
86 ret_t cherokee_balancer_configure_base (cherokee_balancer_t *balancer, cherokee_server_t *srv, cherokee_config_node_t *conf);
87 ret_t cherokee_balancer_mrproper       (cherokee_balancer_t *balancer);
88
89 /* Public methods
90  */
91 ret_t cherokee_balancer_add_source (cherokee_balancer_t *balancer, cherokee_source_t *source);
92
93 /* Virtual methods
94  */
95 ret_t cherokee_balancer_dispatch   (cherokee_balancer_t *balancer, cherokee_connection_t *conn, cherokee_source_t **source);
96 ret_t cherokee_balancer_free       (cherokee_balancer_t *balancer);
97
98 /* Commodity
99  */
100 ret_t cherokee_balancer_instance   (cherokee_buffer_t       *name,
101                                     cherokee_config_node_t  *conf,
102                                     cherokee_server_t       *srv,
103                                     cherokee_balancer_t    **balancer);
104
105 CHEROKEE_END_DECLS
106
107 #endif /* CHEROKEE_BALANCER_H */
Note: See TracBrowser for help on using the browser.