11
11
* @brief Gearman Server Declarations
14
#include <libgearman-server/struct/server.h>
14
#ifndef __GEARMAN_SERVER_H__
15
#define __GEARMAN_SERVER_H__
17
#include <libgearman/gearman.h>
18
#include <libgearman-server/constants.h>
19
#include <libgearman-server/structs.h>
20
#include <libgearman-server/conf.h>
21
#include <libgearman-server/conf_module.h>
22
#include <libgearman-server/conn.h>
23
#include <libgearman-server/packet.h>
24
#include <libgearman-server/function.h>
25
#include <libgearman-server/client.h>
26
#include <libgearman-server/worker.h>
27
#include <libgearman-server/job.h>
28
#include <libgearman-server/thread.h>
24
inline static void gearmand_set_round_robin(gearman_server_st *server, bool round_robin)
26
server->flags.round_robin= round_robin;
35
* @addtogroup gearman_server Server Interface
36
* This is the interface gearman servers should use.
41
* Initialize a server structure. This cannot fail if the caller supplies a
43
* @param server Caller allocated server structure, or NULL to allocate one.
44
* @return Pointer to an allocated server structure if server parameter was
45
* NULL, or the server parameter pointer if it was not NULL.
48
gearman_server_st *gearman_server_create(gearman_server_st *server);
51
* Free resources used by a server structure.
52
* @param server Server structure previously initialized with
53
* gearman_server_create.
56
void gearman_server_free(gearman_server_st *server);
59
* Set maximum job retry count.
60
* @param server Server structure previously initialized with
61
* gearman_server_create.
62
* @param job_retries Number of job attempts.
65
void gearman_server_set_job_retries(gearman_server_st *server,
69
* Set logging callback for server instance.
70
* @param server Server structure previously initialized with
71
* gearman_server_create.
72
* @param function Function to call when there is a logging message.
73
* @param context Argument to pass into the log callback function.
74
* @param verbose Verbosity level.
77
void gearman_server_set_log_fn(gearman_server_st *server,
78
gearman_log_fn *function,
79
const void *context, gearman_verbose_t verbose);
30
82
* Process commands for a connection.
33
85
* @return Standard gearman return value.
36
gearmand_error_t gearman_server_run_command(gearman_server_con_st *server_con,
37
gearmand_packet_st *packet);
88
gearman_return_t gearman_server_run_command(gearman_server_con_st *server_con,
89
gearman_packet_st *packet);
40
92
* Tell server that it should enter a graceful shutdown state.
71
void gearman_server_set_queue(gearman_server_st *server,
73
gearman_queue_add_fn *add,
74
gearman_queue_flush_fn *flush,
75
gearman_queue_done_fn *done,
76
gearman_queue_replay_fn *replay);
123
void gearman_server_set_queue_context(gearman_server_st *server,
124
const void *context);
127
* Set function to call when jobs need to be stored in the persistent queue.
130
void gearman_server_set_queue_add_fn(gearman_server_st *server,
131
gearman_queue_add_fn *function);
134
* Set function to call when the persistent queue should be flushed to disk.
137
void gearman_server_set_queue_flush_fn(gearman_server_st *server,
138
gearman_queue_flush_fn *function);
141
* Set function to call when a job should be removed from the persistent queue.
144
void gearman_server_set_queue_done_fn(gearman_server_st *server,
145
gearman_queue_done_fn *function);
148
* Set function to call when jobs in the persistent queue should be replayed
152
void gearman_server_set_queue_replay_fn(gearman_server_st *server,
153
gearman_queue_replay_fn *function);
80
157
#ifdef __cplusplus
161
#endif /* __GEARMAN_SERVER_H__ */