Gearman Developer Documentation

Gearmand Declarations

Data Structures

struct  gearmand_port_st
struct  gearmand_st

Modules

 Connection Declarations
 Thread Declarations
 Private Gearman Daemon Functions

Enumerations

enum  gearmand_options_t { GEARMAND_LISTEN_EVENT = (1 << 0), GEARMAND_WAKEUP_EVENT = (1 << 1) }
enum  gearmand_wakeup_t {
  GEARMAND_WAKEUP_PAUSE = (1 << 0), GEARMAND_WAKEUP_SHUTDOWN = (1 << 1), GEARMAND_WAKEUP_SHUTDOWN_GRACEFUL = (1 << 2), GEARMAND_WAKEUP_CON = (1 << 3),
  GEARMAND_WAKEUP_RUN = (1 << 4)
}

Functions

gearmand_stgearmand_create (const char *host, in_port_t port)
void gearmand_free (gearmand_st *gearmand)
void gearmand_set_backlog (gearmand_st *gearmand, int backlog)
void gearmand_set_job_retries (gearmand_st *gearmand, uint8_t job_retries)
void gearmand_set_worker_wakeup (gearmand_st *gearmand, uint8_t worker_wakeup)
void gearmand_set_threads (gearmand_st *gearmand, uint32_t threads)
void gearmand_set_log_fn (gearmand_st *gearmand, gearman_log_fn *function, void *context, gearman_verbose_t verbose)
gearman_return_t gearmand_port_add (gearmand_st *gearmand, in_port_t port, gearman_connection_add_fn *function)
gearman_return_t gearmand_run (gearmand_st *gearmand)
void gearmand_wakeup (gearmand_st *gearmand, gearmand_wakeup_t wakeup)
void gearmand_set_round_robin (gearmand_st *gearmand, bool round_robin)

Detailed Description

This is a server implementation using the gearman_server interface.


Enumeration Type Documentation

Options for gearmand_st.

Enumerator:
GEARMAND_LISTEN_EVENT 
GEARMAND_WAKEUP_EVENT 

Definition at line 70 of file constants.h.

Wakeup events for gearmand_st.

Enumerator:
GEARMAND_WAKEUP_PAUSE 
GEARMAND_WAKEUP_SHUTDOWN 
GEARMAND_WAKEUP_SHUTDOWN_GRACEFUL 
GEARMAND_WAKEUP_CON 
GEARMAND_WAKEUP_RUN 

Definition at line 80 of file constants.h.


Function Documentation

gearmand_st* gearmand_create ( const char *  host,
in_port_t  port 
)

Create a server instance.

Parameters:
host Host for the server to listen on.
port Port for the server to listen on.
Returns:
Pointer to an allocated gearmand structure.

Definition at line 51 of file gearmand.c.

void gearmand_free ( gearmand_st gearmand  ) 

Free resources used by a server instace.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.

Definition at line 97 of file gearmand.c.

void gearmand_set_backlog ( gearmand_st gearmand,
int  backlog 
)

Set socket backlog for listening connection.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
backlog Number of backlog connections to set during listen.

Definition at line 139 of file gearmand.c.

void gearmand_set_job_retries ( gearmand_st gearmand,
uint8_t  job_retries 
)

Set maximum job retry count.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
job_retries Number of job attempts.

Definition at line 144 of file gearmand.c.

void gearmand_set_worker_wakeup ( gearmand_st gearmand,
uint8_t  worker_wakeup 
)

Set maximum number of workers to wake up per job.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
worker_wakeup Number of workers to wake up.

Definition at line 149 of file gearmand.c.

void gearmand_set_threads ( gearmand_st gearmand,
uint32_t  threads 
)

Set number of I/O threads for server to use.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
threads Number of threads.

Definition at line 154 of file gearmand.c.

void gearmand_set_log_fn ( gearmand_st gearmand,
gearman_log_fn function,
void *  context,
gearman_verbose_t  verbose 
)

Set logging callback for server instance.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
function Function to call when there is a logging message.
context Argument to pass into the log callback function.
verbose Verbosity level.

Definition at line 159 of file gearmand.c.

gearman_return_t gearmand_port_add ( gearmand_st gearmand,
in_port_t  port,
gearman_connection_add_fn function 
)

Add a port to listen on when starting server with optional callback.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
port Port for the server to listen on.
function Optional callback function that is called when a connection has been accepted on the given port.
Returns:
Standard gearman return value.

Definition at line 168 of file gearmand.c.

gearman_return_t gearmand_run ( gearmand_st gearmand  ) 

Run the server instance.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
Returns:
Standard gearman return value.

Definition at line 194 of file gearmand.c.

void gearmand_wakeup ( gearmand_st gearmand,
gearmand_wakeup_t  wakeup 
)

Interrupt a running gearmand server from another thread. You should only call this when another thread is currently running gearmand_run() and you want to wakeup the server with the given event.

Parameters:
gearmand Server instance structure previously initialized with gearmand_create.
wakeup Wakeup event to send to running gearmand.

Definition at line 273 of file gearmand.c.

void gearmand_set_round_robin ( gearmand_st gearmand,
bool  round_robin 
)

Sets the round-robin mode on the server object. RR will distribute work fairly among every function assigned to a worker, instead of draining each function before moving on to the next.

Parameters:
gearmand Server instance previously initialized
bool true=round robin is used, false=round robin is not used

Definition at line 283 of file gearmand.c.

Generated on Tue Jun 15 11:40:21 2010 by  doxygen 1.6.3