| 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 | |
|---|
| 31 | struct 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 | |
|---|
| 41 | extern |
|---|
| 42 | void |
|---|
| 43 | dispatch_init(struct dispatch_state *state); |
|---|
| 44 | |
|---|
| 45 | extern |
|---|
| 46 | void |
|---|
| 47 | dispatch_destroy(struct dispatch_state *state); |
|---|
| 48 | |
|---|
| 49 | extern |
|---|
| 50 | void |
|---|
| 51 | dispatch_set_ketama_points(struct dispatch_state *state, int ketama_points); |
|---|
| 52 | |
|---|
| 53 | extern |
|---|
| 54 | void |
|---|
| 55 | dispatch_set_prefix(struct dispatch_state *state, |
|---|
| 56 | const char *prefix, size_t prefix_len); |
|---|
| 57 | |
|---|
| 58 | extern |
|---|
| 59 | int |
|---|
| 60 | dispatch_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 | |
|---|
| 65 | extern |
|---|
| 66 | int |
|---|
| 67 | dispatch_key(struct dispatch_state *state, const char *key, size_t key_len); |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | #endif /* ! DISPATCH_KEY_H */ |
|---|