ca81b0d32caba2b2df4f4958acaa8843eedb041b
[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 memcached_allocated is_allocated;
18 char hostname[MEMCACHED_MAX_HOST_LENGTH];
19 unsigned int port;
20 int fd;
21 int cached_errno;
22 unsigned int cursor_active;
23 char write_buffer[MEMCACHED_MAX_BUFFER];
24 size_t write_buffer_offset;
25 char read_buffer[MEMCACHED_MAX_BUFFER];
26 size_t read_data_length;
27 size_t read_buffer_length;
28 char *read_ptr;
29 memcached_allocated sockaddr_inited;
30 struct addrinfo *address_info;
31 memcached_connection type;
32 uint8_t major_version;
33 uint8_t minor_version;
34 uint8_t micro_version;
35 uint16_t count;
36 time_t next_retry;
37 memcached_st *root;
38 uint64_t limit_maxbytes;
39 uint32_t server_failure_counter;
40 uint32_t io_bytes_sent; /* # bytes sent since last read */
41 uint32_t weight;
42 };
43
44 #define memcached_server_count(A) (A)->number_of_hosts
45 #define memcached_server_name(A,B) (B).hostname
46 #define memcached_server_port(A,B) (B).port
47 #define memcached_server_list(A) (A)->hosts
48 #define memcached_server_response_count(A) (A)->cursor_active
49
50 memcached_return memcached_server_cursor(memcached_st *ptr,
51 memcached_server_function *callback,
52 void *context,
53 unsigned int number_of_callbacks);
54
55 memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key,
56 size_t key_length, memcached_return *error);
57
58 /* These should not currently be used by end users */
59 memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr);
60
61 memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
62 const char *hostname, unsigned int port,
63 uint32_t weight, memcached_connection type);
64
65 void memcached_server_free(memcached_server_st *ptr);
66 memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr);
67
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* __MEMCACHED_SERVER_H__ */