Data Structures |
struct | gearman_worker_st |
Modules |
| Constants |
| Types |
| Job Declarations |
| Static Worker Declarations |
Enumerations |
enum | gearman_worker_options_t {
GEARMAN_WORKER_ALLOCATED = (1 << 0),
GEARMAN_WORKER_NON_BLOCKING = (1 << 1),
GEARMAN_WORKER_PACKET_INIT = (1 << 2),
GEARMAN_WORKER_GRAB_JOB_IN_USE = (1 << 3),
GEARMAN_WORKER_PRE_SLEEP_IN_USE = (1 << 4),
GEARMAN_WORKER_WORK_JOB_IN_USE = (1 << 5),
GEARMAN_WORKER_CHANGE = (1 << 6),
GEARMAN_WORKER_GRAB_UNIQ = (1 << 7),
GEARMAN_WORKER_TIMEOUT_RETURN = (1 << 8),
GEARMAN_WORKER_MAX = (1 << 9)
} |
Functions |
gearman_worker_st * | gearman_worker_create (gearman_worker_st *worker) |
gearman_worker_st * | gearman_worker_clone (gearman_worker_st *worker, const gearman_worker_st *from) |
void | gearman_worker_free (gearman_worker_st *worker) |
const char * | gearman_worker_error (gearman_worker_st *worker) |
int | gearman_worker_errno (gearman_worker_st *worker) |
gearman_worker_options_t | gearman_worker_options (const gearman_worker_st *worker) |
void | gearman_worker_set_options (gearman_worker_st *worker, gearman_worker_options_t options) |
void | gearman_worker_add_options (gearman_worker_st *worker, gearman_worker_options_t options) |
void | gearman_worker_remove_options (gearman_worker_st *worker, gearman_worker_options_t options) |
int | gearman_worker_timeout (gearman_worker_st *worker) |
void | gearman_worker_set_timeout (gearman_worker_st *worker, int timeout) |
void * | gearman_worker_context (const gearman_worker_st *worker) |
void | gearman_worker_set_context (gearman_worker_st *worker, void *context) |
void | gearman_worker_set_log_fn (gearman_worker_st *worker, gearman_log_fn *function, void *context, gearman_verbose_t verbose) |
void | gearman_worker_set_workload_malloc_fn (gearman_worker_st *worker, gearman_malloc_fn *function, void *context) |
void | gearman_worker_set_workload_free_fn (gearman_worker_st *worker, gearman_free_fn *function, void *context) |
gearman_return_t | gearman_worker_add_server (gearman_worker_st *worker, const char *host, in_port_t port) |
gearman_return_t | gearman_worker_add_servers (gearman_worker_st *worker, const char *servers) |
void | gearman_worker_remove_servers (gearman_worker_st *worker) |
gearman_return_t | gearman_worker_wait (gearman_worker_st *worker) |
gearman_return_t | gearman_worker_register (gearman_worker_st *worker, const char *function_name, uint32_t timeout) |
gearman_return_t | gearman_worker_unregister (gearman_worker_st *worker, const char *function_name) |
gearman_return_t | gearman_worker_unregister_all (gearman_worker_st *worker) |
gearman_job_st * | gearman_worker_grab_job (gearman_worker_st *worker, gearman_job_st *job, gearman_return_t *ret_ptr) |
void | gearman_job_free_all (gearman_worker_st *worker) |
bool | gearman_worker_function_exist (gearman_worker_st *worker, const char *function_name, size_t function_length) |
gearman_return_t | gearman_worker_add_function (gearman_worker_st *worker, const char *function_name, uint32_t timeout, gearman_worker_fn *function, void *context) |
gearman_return_t | gearman_worker_work (gearman_worker_st *worker) |
gearman_return_t | gearman_worker_echo (gearman_worker_st *worker, const void *workload, size_t workload_size) |
Detailed Description
This is the interface gearman workers should use.
See Main Page for full details.
Enumeration Type Documentation
Options for gearman_worker_st.
- Enumerator:
GEARMAN_WORKER_ALLOCATED |
|
GEARMAN_WORKER_NON_BLOCKING |
|
GEARMAN_WORKER_PACKET_INIT |
|
GEARMAN_WORKER_GRAB_JOB_IN_USE |
|
GEARMAN_WORKER_PRE_SLEEP_IN_USE |
|
GEARMAN_WORKER_WORK_JOB_IN_USE |
|
GEARMAN_WORKER_CHANGE |
|
GEARMAN_WORKER_GRAB_UNIQ |
|
GEARMAN_WORKER_TIMEOUT_RETURN |
|
GEARMAN_WORKER_MAX |
|
Definition at line 222 of file constants.h.
Function Documentation
Initialize a worker structure. Always check the return value even if passing in a pre-allocated structure. Some other initialization may have failed. It is not required to memset() a structure before providing it.
- Parameters:
-
[in] | worker | Caller allocated structure, or NULL to allocate one. |
- Returns:
- On success, a pointer to the (possibly allocated) structure. On failure this will be NULL.
Definition at line 97 of file worker.c.
Clone a worker structure.
- Parameters:
-
[in] | worker | Caller allocated structure, or NULL to allocate one. |
[in] | from | Structure to use as a source to clone from. |
- Returns:
- Same return as gearman_worker_create().
Definition at line 113 of file worker.c.
Free resources used by a worker structure.
- Parameters:
-
Definition at line 154 of file worker.c.
See gearman_error() for details.
Definition at line 191 of file worker.c.
See gearman_errno() for details.
Definition at line 196 of file worker.c.
Get options for a worker structure.
- Parameters:
-
- Returns:
- Options set for the worker structure.
Definition at line 201 of file worker.c.
Set options for a worker structure.
- Parameters:
-
Definition at line 228 of file worker.c.
Add options for a worker structure.
- Parameters:
-
Definition at line 254 of file worker.c.
Remove options for a worker structure.
- Parameters:
-
Definition at line 276 of file worker.c.
Get the application context for a worker.
- Parameters:
-
- Returns:
- Application context that was previously set, or NULL.
Definition at line 309 of file worker.c.
Set the application context for a worker.
- Parameters:
-
Definition at line 314 of file worker.c.
Set custom memory free function for workloads. Normally gearman uses the standard system free to free memory used with workloads. The provided function will be used instead.
- Parameters:
-
[in] | gearman | Structure previously initialized with gearman_universal_create() or gearman_clone(). |
[in] | function | Memory free function to use instead of free(). |
[in] | context | Argument to pass into the callback function. |
Definition at line 333 of file worker.c.
Add a job server to a worker. This goes into a list of servers that can be used to run tasks. No socket I/O happens here, it is just added to a list.
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 340 of file worker.c.
Add a list of job servers to a worker. The format for the server list is: SERVER[:PORT][,SERVER[:PORT]]... Some examples are: 10.0.0.1,10.0.0.2,10.0.0.3 localhost LIBGEARMAN_BITFIELD234,jobserver2.domain.com:7003,10.0.0.3
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 349 of file worker.c.
Remove all servers currently associated with the worker.
- Parameters:
-
Definition at line 355 of file worker.c.
When in non-blocking I/O mode, wait for activity from one of the servers.
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 360 of file worker.c.
Register function with job servers with an optional timeout. The timeout specifies how many seconds the server will wait before marking a job as failed. If timeout is zero, there is no timeout.
- Parameters:
-
[in] | worker | Structure previously initialized with gearman_worker_create() or gearman_worker_clone(). |
[in] | function_name | Function name to register. |
[in] | timeout | Optional timeout (in seconds) that specifies the maximum time a job should. This is enforced on the job server. A value of 0 means an infinite time. |
- Returns:
- Standard gearman return value.
Definition at line 365 of file worker.c.
Unregister function with job servers.
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 417 of file worker.c.
Unregister all functions with job servers.
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 423 of file worker.c.
Get a job from one of the job servers. This does not used the callback interface below, which means results must be sent back to the job server manually. It is also the responsibility of the caller to free the job once it has been completed.
- Parameters:
-
- Returns:
- On success, a pointer to the (possibly allocated) structure. On failure this will be NULL.
Definition at line 469 of file worker.c.
Free all jobs for a gearman structure.
- Parameters:
-
Definition at line 751 of file worker.c.
bool gearman_worker_function_exist |
( |
gearman_worker_st * |
worker, |
|
|
const char * |
function_name, |
|
|
size_t |
function_length |
|
) |
| |
See if a function exists in the server. It will not return true if the function is currently being de-allocated.
- Parameters:
-
[in] | worker | gearman_worker_st that will be used. |
[in] | function_name | Function name for search. |
[in] | function_length | Length of function name. |
- Returns:
- bool
Definition at line 372 of file worker.c.
Register and add callback function for worker. To remove functions that have been added, call gearman_worker_unregister() or gearman_worker_unregister_all().
- Parameters:
-
[in] | worker | Structure previously initialized with gearman_worker_create() or gearman_worker_clone(). |
[in] | function_name | Function name to register. |
[in] | timeout | Optional timeout (in seconds) that specifies the maximum time a job should. This is enforced on the job server. A value of 0 means an infinite time. |
[in] | function | Function to run when there is a job ready. |
[in] | context | Argument to pass into the callback function. |
- Returns:
- Standard gearman return value.
Definition at line 757 of file worker.c.
Wait for a job and call the appropriate callback function when it gets one.
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 784 of file worker.c.
Send data to all job servers to see if they echo it back. This is a test function to see if job servers are responding properly.
- Parameters:
-
- Returns:
- Standard gearman return value.
Definition at line 912 of file worker.c.