aboutsummaryrefslogtreecommitdiffstats
path: root/src/upstream.h
blob: a6c6b22005d7e172f8ffcdfd67b4e1f24eeaeb01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef UPSTREAM_H
#define UPSTREAM_H

#include <sys/types.h>
#include <stdint.h>

struct upstream {
	unsigned int errors;
	time_t time;
	unsigned char dead;
	unsigned char priority;
	int16_t weight;
	uint32_t *ketama_points;
	size_t ketama_points_size;
};

void upstream_fail (struct upstream *up, time_t now);
void upstream_ok (struct upstream *up, time_t now);
void revive_all_upstreams (void *ups, size_t members, size_t msize);
int upstream_ketama_add (struct upstream *up, char *up_key, size_t keylen, size_t keypoints);

struct upstream* get_random_upstream   (void *ups, size_t members, size_t msize, 
										time_t now, time_t error_timeout, 
										time_t revive_timeout, size_t max_errors);

struct upstream* get_upstream_by_hash  (void *ups, size_t members, size_t msize, 
										time_t now,  time_t error_timeout, 
										time_t revive_timeout, size_t max_errors,
										char *key, size_t keylen);

struct upstream* get_upstream_round_robin (void *ups, size_t members, size_t msize, 
										time_t now, time_t error_timeout, 
										time_t revive_timeout, size_t max_errors);

struct upstream* get_upstream_by_hash_ketama (void *ups, size_t members, size_t msize, time_t now, 
										time_t error_timeout, time_t revive_timeout, size_t max_errors,
										char *key, size_t keylen);


#endif /* UPSTREAM_H */
/* 
 * vi:ts=4 
 */