e0fc7ea14ba4b7a25ad672ac08fbb535b76389de
[m6w6/libmemcached] / libmemcached / memcached_server.h
1 /*
2 * Summary: String structure used for libmemcached.
3 *
4 * Copy: See Copyright for the status of this software.
5 *
6 * Author: Brian Aker
7 */
8
9 #ifndef __MEMCACHED_SERVER_H__
10 #define __MEMCACHED_SERVER_H__
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 struct memcached_server_st {
17 struct {
18 bool is_allocated:1;
19 } options;
20 bool sockaddr_inited;
21 uint16_t count;
22 uint32_t cursor_active;
23 in_port_t port;
24 int cached_errno;
25 int fd;
26 uint32_t io_bytes_sent; /* # bytes sent since last read */
27 uint32_t server_failure_counter;
28 uint32_t weight;
29 uint8_t major_version;
30 uint8_t micro_version;
31 uint8_t minor_version;
32 memcached_connection_t type;
33 char *read_ptr;
34 char *cached_server_error;
35 size_t read_buffer_length;
36 size_t read_data_length;
37 size_t write_buffer_offset;
38 struct addrinfo *address_info;
39 time_t next_retry;
40 memcached_st *root;
41 uint64_t limit_maxbytes;
42 char read_buffer[MEMCACHED_MAX_BUFFER];
43 char write_buffer[MEMCACHED_MAX_BUFFER];
44 char hostname[MEMCACHED_MAX_HOST_LENGTH];
45 };
46
47 #define memcached_server_count(A) (A)->number_of_hosts
48 #define memcached_server_name(A,B) (B).hostname
49 #define memcached_server_port(A,B) (B).port
50 #define memcached_server_list(A) (A)->hosts
51 #define memcached_server_response_count(A) (A)->cursor_active
52
53 LIBMEMCACHED_API
54 memcached_return_t memcached_server_cursor(memcached_st *ptr,
55 memcached_server_fn *callback,
56 void *context,
57 uint32_t number_of_callbacks);
58
59 LIBMEMCACHED_API
60 memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key,
61 size_t key_length, memcached_return_t *error);
62
63 LIBMEMCACHED_API
64 const char *memcached_server_error(memcached_server_st *ptr);
65
66 LIBMEMCACHED_API
67 void memcached_server_error_reset(memcached_server_st *ptr);
68
69 /* These should not currently be used by end users */
70 /* TODO: Is the above comment valid? If so, how can we unit test these if they
71 * aren't exported. If not, we should remove the comment */
72 LIBMEMCACHED_API
73 memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr);
74
75 LIBMEMCACHED_API
76 memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
77 const char *hostname, in_port_t port,
78 uint32_t weight, memcached_connection_t type);
79
80 LIBMEMCACHED_API
81 void memcached_server_free(memcached_server_st *ptr);
82 LIBMEMCACHED_API
83 memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr);
84 LIBMEMCACHED_API
85 memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat,
86 memcached_return_t *error);
87
88 LIBMEMCACHED_API
89 memcached_return_t memcached_server_remove(memcached_server_st *st_ptr);
90
91 LIBMEMCACHED_API
92 memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr);
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* __MEMCACHED_SERVER_H__ */