2 * Copyright (C) 2006-2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
8 * Summary: String structure used for libmemcached.
12 #ifndef __MEMCACHED_SERVER_H__
13 #define __MEMCACHED_SERVER_H__
19 struct memcached_server_st
{
22 bool sockaddr_inited
:1;
24 uint32_t number_of_hosts
;
25 uint32_t cursor_active
;
29 uint32_t io_bytes_sent
; /* # bytes sent since last read */
30 uint32_t server_failure_counter
;
32 uint8_t major_version
;
33 uint8_t micro_version
;
34 uint8_t minor_version
;
35 memcached_connection_t type
;
37 char *cached_server_error
;
38 size_t read_buffer_length
;
39 size_t read_data_length
;
40 size_t write_buffer_offset
;
41 struct addrinfo
*address_info
;
44 uint64_t limit_maxbytes
;
45 char read_buffer
[MEMCACHED_MAX_BUFFER
];
46 char write_buffer
[MEMCACHED_MAX_BUFFER
];
47 char hostname
[MEMCACHED_MAX_HOST_LENGTH
];
51 static inline uint32_t memcached_servers_count(memcached_server_st
*servers
)
53 return servers
->number_of_hosts
;
57 static inline uint32_t memcached_servers_set_count(memcached_server_st
*servers
, uint32_t count
)
59 return servers
->number_of_hosts
= count
;
64 #define memcached_server_count(A) (A)->number_of_hosts
65 #define memcached_server_name(A,B) (B).hostname
66 #define memcached_server_port(A,B) (B).port
67 #define memcached_server_list(A) (A)->hosts
68 #define memcached_server_list_set(A,B) (A)->hosts=(B)
69 #define memcached_server_response_count(A) (A)->cursor_active
72 memcached_return_t
memcached_server_cursor(memcached_st
*ptr
,
73 memcached_server_fn
*callback
,
75 uint32_t number_of_callbacks
);
78 memcached_server_st
*memcached_server_by_key(memcached_st
*ptr
,
81 memcached_return_t
*error
);
84 const char *memcached_server_error(memcached_server_st
*ptr
);
87 void memcached_server_error_reset(memcached_server_st
*ptr
);
89 /* These should not currently be used by end users */
90 /* TODO: Is the above comment valid? If so, how can we unit test these if they
91 * aren't exported. If not, we should remove the comment */
93 memcached_server_st
*memcached_server_create(memcached_st
*memc
, memcached_server_st
*ptr
);
96 memcached_server_st
*memcached_server_create_with(memcached_st
*memc
,
97 memcached_server_st
*host
,
101 memcached_connection_t type
);
104 void memcached_server_free(memcached_server_st
*ptr
);
107 memcached_server_st
*memcached_server_clone(memcached_server_st
*clone
,
108 memcached_server_st
*ptr
);
111 memcached_return_t
memcached_server_remove(memcached_server_st
*st_ptr
);
114 memcached_server_st
*memcached_server_get_last_disconnect(memcached_st
*ptr
);
120 #endif /* __MEMCACHED_SERVER_H__ */