Merge Trond.
[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 bool is_allocated;
18 bool sockaddr_inited;
19 uint16_t count;
20 unsigned int cursor_active;
21 unsigned int port;
22 int cached_errno;
23 int fd;
24 uint32_t io_bytes_sent; /* # bytes sent since last read */
25 uint32_t server_failure_counter;
26 uint32_t weight;
27 uint8_t major_version;
28 uint8_t micro_version;
29 uint8_t minor_version;
30 memcached_connection type;
31 char *read_ptr;
32 char *cached_server_error;
33 size_t read_buffer_length;
34 size_t read_data_length;
35 size_t write_buffer_offset;
36 struct addrinfo *address_info;
37 time_t next_retry;
38 memcached_st *root;
39 uint64_t limit_maxbytes;
40 char read_buffer[MEMCACHED_MAX_BUFFER];
41 char write_buffer[MEMCACHED_MAX_BUFFER];
42 char hostname[MEMCACHED_MAX_HOST_LENGTH];
43 };
44
45 #define memcached_server_count(A) (A)->number_of_hosts
46 #define memcached_server_name(A,B) (B).hostname
47 #define memcached_server_port(A,B) (B).port
48 #define memcached_server_list(A) (A)->hosts
49 #define memcached_server_response_count(A) (A)->cursor_active
50
51 LIBMEMCACHED_API
52 memcached_return memcached_server_cursor(memcached_st *ptr,
53 memcached_server_function *callback,
54 void *context,
55 unsigned int number_of_callbacks);
56
57 LIBMEMCACHED_API
58 memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key,
59 size_t key_length, memcached_return *error);
60
61 LIBMEMCACHED_API
62 const char *memcached_server_error(memcached_server_st *ptr);
63
64 LIBMEMCACHED_API
65 void memcached_server_error_reset(memcached_server_st *ptr);
66
67 /* These should not currently be used by end users */
68 /* TODO: Is the above comment valid? If so, how can we unit test these if they
69 * aren't exported. If not, we should remove the comment */
70 LIBMEMCACHED_API
71 memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr);
72
73 LIBMEMCACHED_API
74 memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
75 const char *hostname, unsigned int port,
76 uint32_t weight, memcached_connection type);
77
78 LIBMEMCACHED_API
79 void memcached_server_free(memcached_server_st *ptr);
80 LIBMEMCACHED_API
81 memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr);
82 LIBMEMCACHED_API
83 memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat,
84 memcached_return *error);
85
86 LIBMEMCACHED_API
87 memcached_return memcached_server_remove(memcached_server_st *st_ptr);
88
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif /* __MEMCACHED_SERVER_H__ */