1
/* Gearman server and library
2
* Copyright (C) 2008 Brian Aker, Eric Day
5
* Use and distribution licensed under the BSD license. See
6
* the COPYING file in the parent directory for full text.
11
* @brief Struct definitions
14
#ifndef __GEARMAN_SERVER_STRUCTS_H__
15
#define __GEARMAN_SERVER_STRUCTS_H__
22
* @ingroup gearman_server
24
struct gearman_server_st
26
gearman_server_options_t options;
28
bool shutdown_graceful;
32
uint32_t job_handle_count;
33
uint32_t thread_count;
34
uint32_t function_count;
36
uint32_t unique_count;
37
uint32_t free_packet_count;
38
uint32_t free_job_count;
39
uint32_t free_client_count;
40
uint32_t free_worker_count;
42
gearman_server_thread_st *thread_list;
43
gearman_server_function_st *function_list;
44
gearman_server_packet_st *free_packet_list;
45
gearman_server_job_st *free_job_list;
46
gearman_server_client_st *free_client_list;
47
gearman_server_worker_st *free_worker_list;
48
gearman_log_fn *log_fn;
49
const void *log_context;
50
const void *queue_context;
51
gearman_queue_add_fn *queue_add_fn;
52
gearman_queue_flush_fn *queue_flush_fn;
53
gearman_queue_done_fn *queue_done_fn;
54
gearman_queue_replay_fn *queue_replay_fn;
55
gearman_st gearman_static;
56
pthread_mutex_t proc_lock;
57
pthread_cond_t proc_cond;
59
char job_handle_prefix[GEARMAN_JOB_HANDLE_SIZE];
60
gearman_server_job_st *job_hash[GEARMAN_JOB_HASH_SIZE];
61
gearman_server_job_st *unique_hash[GEARMAN_JOB_HASH_SIZE];
65
* @ingroup gearman_server_thread
67
struct gearman_server_thread_st
69
gearman_server_thread_options_t options;
73
uint32_t free_con_count;
74
uint32_t free_packet_count;
76
gearman_server_st *server;
77
gearman_server_thread_st *next;
78
gearman_server_thread_st *prev;
79
gearman_log_fn *log_fn;
80
const void *log_context;
81
gearman_server_thread_run_fn *run_fn;
83
gearman_server_con_st *con_list;
84
gearman_server_con_st *io_list;
85
gearman_server_con_st *proc_list;
86
gearman_server_con_st *free_con_list;
87
gearman_server_packet_st *free_packet_list;
88
gearman_st gearman_static;
93
* @ingroup gearman_server_con
95
struct gearman_server_con_st
97
gearman_con_st con; /* This must be the first struct member. */
98
gearman_server_con_options_t options;
103
uint32_t io_packet_count;
104
uint32_t proc_packet_count;
105
uint32_t worker_count;
106
uint32_t client_count;
107
gearman_server_thread_st *thread;
108
gearman_server_con_st *next;
109
gearman_server_con_st *prev;
110
gearman_server_packet_st *packet;
111
gearman_server_packet_st *io_packet_list;
112
gearman_server_packet_st *io_packet_end;
113
gearman_server_packet_st *proc_packet_list;
114
gearman_server_packet_st *proc_packet_end;
115
gearman_server_con_st *io_next;
116
gearman_server_con_st *io_prev;
117
gearman_server_con_st *proc_next;
118
gearman_server_con_st *proc_prev;
119
gearman_server_worker_st *worker_list;
120
gearman_server_client_st *client_list;
123
char id[GEARMAN_SERVER_CON_ID_SIZE];
127
* @ingroup gearman_server_con
129
struct gearman_server_packet_st
131
gearman_packet_st packet;
132
gearman_server_packet_st *next;
136
* @ingroup gearman_server_function
138
struct gearman_server_function_st
140
gearman_server_function_options_t options;
141
uint32_t worker_count;
144
uint32_t job_running;
145
uint32_t max_queue_size;
146
size_t function_name_size;
147
gearman_server_st *server;
148
gearman_server_function_st *next;
149
gearman_server_function_st *prev;
151
gearman_server_worker_st *worker_list;
152
gearman_server_job_st *job_list[GEARMAN_JOB_PRIORITY_MAX];
153
gearman_server_job_st *job_end[GEARMAN_JOB_PRIORITY_MAX];
157
* @ingroup gearman_server_client
159
struct gearman_server_client_st
161
gearman_server_client_options_t options;
162
gearman_server_con_st *con;
163
gearman_server_client_st *con_next;
164
gearman_server_client_st *con_prev;
165
gearman_server_job_st *job;
166
gearman_server_client_st *job_next;
167
gearman_server_client_st *job_prev;
171
* @ingroup gearman_server_worker
173
struct gearman_server_worker_st
175
gearman_server_worker_options_t options;
178
gearman_server_con_st *con;
179
gearman_server_worker_st *con_next;
180
gearman_server_worker_st *con_prev;
181
gearman_server_function_st *function;
182
gearman_server_worker_st *function_next;
183
gearman_server_worker_st *function_prev;
184
gearman_server_job_st *job_list;
188
* @ingroup gearman_server_job
190
struct gearman_server_job_st
193
gearman_server_job_options_t options;
194
gearman_job_priority_t priority;
195
uint32_t job_handle_key;
197
uint32_t client_count;
199
uint32_t denominator;
201
gearman_server_st *server;
202
gearman_server_job_st *next;
203
gearman_server_job_st *prev;
204
gearman_server_job_st *unique_next;
205
gearman_server_job_st *unique_prev;
206
gearman_server_job_st *worker_next;
207
gearman_server_job_st *worker_prev;
208
gearman_server_function_st *function;
209
gearman_server_job_st *function_next;
211
gearman_server_client_st *client_list;
212
gearman_server_worker_st *worker;
213
char job_handle[GEARMAN_JOB_HANDLE_SIZE];
214
char unique[GEARMAN_UNIQUE_SIZE];
222
gearmand_options_t options;
223
gearman_verbose_t verbose;
224
gearman_return_t ret;
228
uint32_t thread_count;
229
uint32_t free_dcon_count;
230
uint32_t max_thread_free_dcon_count;
233
gearman_log_fn *log_fn;
234
const void *log_context;
235
struct event_base *base;
236
gearmand_port_st *port_list;
237
gearmand_thread_st *thread_list;
238
gearmand_thread_st *thread_add_next;
239
gearmand_con_st *free_dcon_list;
240
gearman_server_st server;
241
struct event wakeup_event;
247
struct gearmand_port_st
250
uint32_t listen_count;
251
gearmand_st *gearmand;
252
gearman_con_add_fn *add_fn;
254
struct event *listen_event;
258
* @ingroup gearmand_thread
260
struct gearmand_thread_st
262
gearmand_thread_options_t options;
265
uint32_t dcon_add_count;
266
uint32_t free_dcon_count;
268
gearmand_thread_st *next;
269
gearmand_thread_st *prev;
270
gearmand_st *gearmand;
271
struct event_base *base;
272
gearmand_con_st *dcon_list;
273
gearmand_con_st *dcon_add_list;
274
gearmand_con_st *free_dcon_list;
275
gearman_server_thread_st server_thread;
276
struct event wakeup_event;
278
pthread_mutex_t lock;
282
* @ingroup gearmand_con
284
struct gearmand_con_st
288
gearmand_thread_st *thread;
289
gearmand_con_st *next;
290
gearmand_con_st *prev;
291
gearman_server_con_st *server_con;
293
gearman_con_add_fn *add_fn;
295
char host[NI_MAXHOST];
296
char port[NI_MAXSERV];
300
* @ingroup gearman_conf
302
struct gearman_conf_st
304
gearman_conf_options_t options;
305
gearman_return_t last_return;
310
gearman_conf_module_st **module_list;
311
gearman_conf_option_st *option_list;
312
struct option *option_getopt;
313
char option_short[GEARMAN_CONF_MAX_OPTION_SHORT];
314
char last_error[GEARMAN_MAX_ERROR_SIZE];
318
* @ingroup gearman_conf
320
struct gearman_conf_option_st
323
gearman_conf_module_st *module;
325
const char *value_name;
331
* @ingroup gearman_conf_module
333
struct gearman_conf_module_st
335
gearman_conf_module_options_t options;
336
size_t current_option;
337
size_t current_value;
338
gearman_conf_st *conf;
346
#endif /* __GEARMAN_SERVER_STRUCTS_H__ */