blob: a6f1c9f4d78c6d6e7e8164b99c5f61eef1066416 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/proto/backend.h
3 Functions prototypes for the backend.
4
Willy Tarreauf89c1872009-10-01 11:19:37 +02005 Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
Willy Tarreaubaaee002006-06-26 02:48:02 +02006
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef _PROTO_BACKEND_H
23#define _PROTO_BACKEND_H
24
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020025#include <common/config.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020026
27#include <types/backend.h>
Willy Tarreauf89c1872009-10-01 11:19:37 +020028#include <types/proxy.h>
29#include <types/server.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030#include <types/session.h>
31
Willy Tarreaubaaee002006-06-26 02:48:02 +020032int assign_server(struct session *s);
33int assign_server_address(struct session *s);
34int assign_server_and_queue(struct session *s);
35int connect_server(struct session *s);
Willy Tarreaubaaee002006-06-26 02:48:02 +020036int srv_redispatch_connect(struct session *t);
Krzysztof Piotr Oledzki15514c22010-01-04 16:03:09 +010037const char *backend_lb_algo_str(int algo);
Willy Tarreaua0cbda62007-11-01 21:39:54 +010038int backend_parse_balance(const char **args, char *err,
39 int errlen, struct proxy *curproxy);
Willy Tarreaubaaee002006-06-26 02:48:02 +020040
Krzysztof Oledzki85130942007-10-22 16:21:10 +020041int be_downtime(struct proxy *px);
Willy Tarreauc5d9c802009-10-01 09:17:05 +020042void recount_servers(struct proxy *px);
43void update_backend_weight(struct proxy *px);
Willy Tarreauca7d4b92009-10-01 09:21:55 +020044struct server *get_server_sh(struct proxy *px, const char *addr, int len);
45struct server *get_server_uh(struct proxy *px, char *uri, int uri_len);
Willy Tarreauc5d9c802009-10-01 09:17:05 +020046
47/* This function returns non-zero if a server with the given weight and state
48 * is usable for LB, otherwise zero.
49 */
50static inline int srv_is_usable(int state, int weight)
51{
52 if (!weight)
53 return 0;
54 if (state & SRV_GOINGDOWN)
55 return 0;
56 if (!(state & SRV_RUNNING))
57 return 0;
58 return 1;
59}
Willy Tarreaubaaee002006-06-26 02:48:02 +020060
Willy Tarreaubaaee002006-06-26 02:48:02 +020061#endif /* _PROTO_BACKEND_H */
62
63/*
64 * Local variables:
65 * c-indent-level: 8
66 * c-basic-offset: 8
67 * End:
68 */