-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibconsistent.h
44 lines (37 loc) · 1.45 KB
/
libconsistent.h
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
44
#ifndef LIBCONSISTENT_H
#define LIBCONSISTENT_H
#include <stdint.h>
#define MAX_NAME_LEN 256
typedef struct _server_info {
char name[MAX_NAME_LEN+1];
int shard_id; //FIXME this is only for jump hashing
} server_info;
typedef struct _cons_hash cons_hash;
typedef struct _ketama_hash ketama_hash;
typedef struct _jump_hash jump_hash;
/* consistent hashing */
cons_hash *chash_create(void);
server_info *chash_add_server(cons_hash *consh,
const char *name);
void chash_del_server(cons_hash *consh,
server_info *srvr);
server_info* chash_get_server(cons_hash *consh,
const char *key);
void chash_destroy(cons_hash *consh);
/* ketama consistent hashing */
ketama_hash *ketama_create(void);
server_info *ketama_add_server(ketama_hash *ketamah,
const char *name);
void ketama_del_server(ketama_hash *ketamah,
server_info *srvr);
server_info *ketama_get_server(ketama_hash *ketamah,
const char *key);
void ketama_destroy(ketama_hash *ketamah);
/* jump consistent hashing */
jump_hash *jump_create(void);
server_info *jump_add_server(jump_hash *jumph,
const char *name);
server_info *jump_get_server(jump_hash *jumph,
const char *key);
void jump_destroy(jump_hash *jumph);
#endif