Gearman Developer Documentation

libgearman-server/gearmand.h
Go to the documentation of this file.
00001 /* Gearman server and library
00002  * Copyright (C) 2008 Brian Aker, Eric Day
00003  * All rights reserved.
00004  *
00005  * Use and distribution licensed under the BSD license.  See
00006  * the COPYING file in the parent directory for full text.
00007  */
00008 
00014 #ifndef __GEARMAND_H__
00015 #define __GEARMAND_H__
00016 
00017 #include <libgearman/gearman.h>
00018 #include <event.h>
00019 
00020 #include <libgearman-server/constants.h>
00021 #include <libgearman-server/log.h>
00022 #include <libgearman-server/conf.h>
00023 #include <libgearman-server/conf_module.h>
00024 #include <libgearman-server/connection.h>
00025 #include <libgearman-server/packet.h>
00026 #include <libgearman-server/function.h>
00027 #include <libgearman-server/client.h>
00028 #include <libgearman-server/worker.h>
00029 #include <libgearman-server/job.h>
00030 #include <libgearman-server/thread.h>
00031 #include <libgearman-server/server.h>
00032 #include <libgearman-server/gearmand_thread.h>
00033 #include <libgearman-server/gearmand_con.h>
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00047 struct gearmand_port_st
00048 {
00049   in_port_t port;
00050   uint32_t listen_count;
00051   gearmand_st *gearmand;
00052   gearman_connection_add_fn *add_fn;
00053   int *listen_fd;
00054   struct event *listen_event;
00055 };
00056 
00057 struct gearmand_st
00058 {
00059   gearman_verbose_t verbose;
00060   gearman_return_t ret;
00061   int backlog;
00062   bool is_listen_event;
00063   bool is_wakeup_event;
00064   uint32_t port_count;
00065   uint32_t threads;
00066   uint32_t thread_count;
00067   uint32_t free_dcon_count;
00068   uint32_t max_thread_free_dcon_count;
00069   int wakeup_fd[2];
00070   const char *host;
00071   gearman_log_fn *log_fn;
00072   void *log_context;
00073   struct event_base *base;
00074   gearmand_port_st *port_list;
00075   gearmand_thread_st *thread_list;
00076   gearmand_thread_st *thread_add_next;
00077   gearmand_con_st *free_dcon_list;
00078   gearman_server_st server;
00079   struct event wakeup_event;
00080 };
00081 
00088 GEARMAN_API
00089 gearmand_st *gearmand_create(const char *host, in_port_t port);
00090 
00096 GEARMAN_API
00097 void gearmand_free(gearmand_st *gearmand);
00098 
00105 GEARMAN_API
00106 void gearmand_set_backlog(gearmand_st *gearmand, int backlog);
00107 
00114 GEARMAN_API
00115 void gearmand_set_job_retries(gearmand_st *gearmand, uint8_t job_retries);
00116 
00123 GEARMAN_API
00124 void gearmand_set_worker_wakeup(gearmand_st *gearmand, uint8_t worker_wakeup);
00125 
00132 GEARMAN_API
00133 void gearmand_set_threads(gearmand_st *gearmand, uint32_t threads);
00134 
00143 GEARMAN_API
00144 void gearmand_set_log_fn(gearmand_st *gearmand, gearman_log_fn *function,
00145                          void *context, gearman_verbose_t verbose);
00146 
00156 GEARMAN_API
00157 gearman_return_t gearmand_port_add(gearmand_st *gearmand, in_port_t port,
00158                                    gearman_connection_add_fn *function);
00159 
00166 GEARMAN_API
00167 gearman_return_t gearmand_run(gearmand_st *gearmand);
00168 
00177 GEARMAN_API
00178 void gearmand_wakeup(gearmand_st *gearmand, gearmand_wakeup_t wakeup);
00179 
00187 GEARMAN_API
00188 void gearmand_set_round_robin(gearmand_st *gearmand, bool round_robin);
00189 
00192 #ifdef __cplusplus
00193 }
00194 #endif
00195 
00196 #endif /* __GEARMAND_H__ */