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 struct { // Place any "state" sort variables in here.
35 uint8_t major_version
;
36 uint8_t micro_version
;
37 uint8_t minor_version
;
38 memcached_connection_t type
;
40 char *cached_server_error
;
41 size_t read_buffer_length
;
42 size_t read_data_length
;
43 size_t write_buffer_offset
;
44 struct addrinfo
*address_info
;
47 uint64_t limit_maxbytes
;
48 char read_buffer
[MEMCACHED_MAX_BUFFER
];
49 char write_buffer
[MEMCACHED_MAX_BUFFER
];
50 char hostname
[MEMCACHED_MAX_HOST_LENGTH
];
54 static inline uint32_t memcached_servers_count(memcached_server_st
*servers
)
56 return servers
->number_of_hosts
;
60 static inline uint32_t memcached_servers_set_count(memcached_server_st
*servers
, uint32_t count
)
62 return servers
->number_of_hosts
= count
;
67 #define memcached_server_count(A) (A)->number_of_hosts
68 #define memcached_server_name(A,B) (B).hostname
69 #define memcached_server_port(A,B) (B).port
70 #define memcached_server_list(A) (A)->servers
71 #define memcached_server_list_set(A,B) (A)->servers=(B)
72 #define memcached_server_response_count(A) (A)->cursor_active
75 memcached_return_t
memcached_server_cursor(memcached_st
*ptr
,
76 memcached_server_fn
*callback
,
78 uint32_t number_of_callbacks
);
81 memcached_server_st
*memcached_server_by_key(memcached_st
*ptr
,
84 memcached_return_t
*error
);
87 const char *memcached_server_error(memcached_server_st
*ptr
);
90 void memcached_server_error_reset(memcached_server_st
*ptr
);
92 /* These should not currently be used by end users */
93 /* TODO: Is the above comment valid? If so, how can we unit test these if they
94 * aren't exported. If not, we should remove the comment */
96 memcached_server_st
*memcached_server_create(memcached_st
*memc
, memcached_server_st
*ptr
);
99 memcached_server_st
*memcached_server_create_with(memcached_st
*memc
,
100 memcached_server_st
*host
,
101 const char *hostname
,
104 memcached_connection_t type
);
107 void memcached_server_free(memcached_server_st
*ptr
);
110 memcached_server_st
*memcached_server_clone(memcached_server_st
*clone
,
111 memcached_server_st
*ptr
);
114 memcached_return_t
memcached_server_remove(memcached_server_st
*st_ptr
);
117 memcached_server_st
*memcached_server_get_last_disconnect(memcached_st
*ptr
);
123 #endif /* __MEMCACHED_SERVER_H__ */