source: src/dispatch_key.h @ 9b5de9

Revision 9b5de9, 1.7 KB checked in by Tomash Brechko <tomash.brechko@…>, 4 years ago (diff)

Optimize single server case for Ketama.

  • Property mode set to 100644
Line 
1/*
2  Copyright (C) 2007-2008 Tomash Brechko.  All rights reserved.
3
4  When used to build Perl module:
5
6  This library is free software; you can redistribute it and/or modify
7  it under the same terms as Perl itself, either Perl version 5.8.8
8  or, at your option, any later version of Perl 5 you may have
9  available.
10
11  When used as a standalone library:
12
13  This library is free software; you can redistribute it and/or modify
14  it under the terms of the GNU Lesser General Public License as
15  published by the Free Software Foundation; either version 2.1 of the
16  License, or (at your option) any later version.
17
18  This library is distributed in the hope that it will be useful, but
19  WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  Lesser General Public License for more details.
22*/
23
24#ifndef DISPATCH_KEY_H
25#define DISPATCH_KEY_H 1
26
27#include "array.h"
28#include <stddef.h>
29
30
31struct dispatch_state
32{
33  struct array buckets;
34  double total_weight;
35  int ketama_points;
36  unsigned int prefix_hash;
37  int server_count;
38};
39
40
41extern
42void
43dispatch_init(struct dispatch_state *state);
44
45extern
46void
47dispatch_destroy(struct dispatch_state *state);
48
49extern
50void
51dispatch_set_ketama_points(struct dispatch_state *state, int ketama_points);
52
53extern
54void
55dispatch_set_prefix(struct dispatch_state *state,
56                    const char *prefix, size_t prefix_len);
57
58extern
59int
60dispatch_add_server(struct dispatch_state *state,
61                    const char *host, size_t host_len,
62                    const char *port, size_t port_len,
63                    double weight, int index);
64
65extern
66int
67dispatch_key(struct dispatch_state *state, const char *key, size_t key_len);
68
69
70#endif /* ! DISPATCH_KEY_H */
Note: See TracBrowser for help on using the repository browser.