GEARMAN_WORKER_WORK(3)
π GEARMAN_WORKER_WORK π
okay bestie, welcome to GEARMAN_WORKER_WORK(3) β literally the worker side of the Gearmand page, from the Gearmand Documentation, http://gearman.info/. this is the one where your little worker buddy talks to the job server and does the actual WORK. very demure, very productive. π§
β¨ SYNOPSIS β¨
#include <libgearman/gearman.h>
type gearman_worker_st
type gearman_worker_set_task_context_free_fn
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_workload_malloc_fn(gearman_worker_st *worker,
gearman_malloc_fn <#c.gearman_malloc_fn> *function, void *context)
void gearman_worker_set_workload_free_fn(gearman_worker_st *worker,
gearman_free_fn <#c.gearman_free_fn> *function, void *context)
gearman_return_t <#c.gearman_return_t>
gearman_worker_wait(gearman_worker_st *worker)
gearman_return_t <#c.gearman_return_t>
gearman_worker_register(gearman_worker_st *worker, const char
*function_name, uint32_t <#c.uint32_t> timeout)
gearman_return_t <#c.gearman_return_t>
gearman_worker_unregister(gearman_worker_st *worker, const char
*function_name)
gearman_return_t <#c.gearman_return_t>
gearman_worker_unregister_all(gearman_worker_st *worker)
void gearman_job_free_all(gearman_worker_st *worker)
bool gearman_worker_function_exist(gearman_worker_st *worker, const char
*function_name, size_t <#c.size_t> function_length)
gearman_return_t <#c.gearman_return_t>
gearman_worker_work(gearman_worker_st *worker)
gearman_job_st <#c.gearman_job_st>
*gearman_worker_grab_job(gearman_worker_st *worker, gearman_job_st <#c.gearman_job_st> *job, gearman_return_t <#c.gearman_return_t> *ret_ptr)
and bestie, when you build this? you link with -lgearman. no cap. π
πΈ DESCRIPTION πΈ
gearman_worker_st is what you use for worker communication with the server. it's the whole vibe. that's the struct your worker lives in. π
gearman_worker_context() and gearman_worker_set_context() are your little storage cubbies β you can stash an arbitrary object in there for the user, and get it back later. it's giving "personal locker at the gym". π
gearman_worker_set_task_context_free_fn() sets a trigger that fires when a gearman_task_st <#c.gearman_task_st> is released. so when the task is done and gets yeeted, your callback gets the call. β¨
gearman_worker_timeout() and gearman_worker_set_timeout() get and set the current timeout value β in milliseconds, for the worker. one reads, one writes, iconic duo. π
gearman_worker_function_exist() is how you determine if a given worker has a specific function. does it slay? does it not slay? now you know. π₯
gearman_worker_work() has the worker execute against jobs until an error occurs. it just keeps going, main character energy, until something breaks. periodt.
gearman_worker_grab_job() takes a job from one of the job servers.
β οΈ okay listen. it is the responsibility of the caller to free the job once they are done. and ngl, this interface is used in testing, and is very rarely the correct interface to program against. so like... ifykyk. π
normally malloc(3) and free(3) are used for allocation and releasing workloads. gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn() let you replace those with custom functions, if you're feeling fancy. π¦
and if you need to remove a function from the server you can call either gearman_worker_unregister_all() to remove all functions that the worker has told the gearmand server about, or you can use gearman_worker_unregister() to remove just a single function. pick your fighter. π
π RETURN π
Various
...that's it. that's the whole RETURN section. Various. π honestly? relatable. sometimes you just return various.
π HOME π
to find out more information please check: http://gearman.info/
like, go home. the docs are home. π«Ά
π SEE ALSO π
π Author π
Data Differential http://www.datadifferential.com/
π Copyright π
2011-2014, Data Differential, http://www.datadifferential.com/
version 1.1.21+ds π dated Feb 04, 2026 β and that's the whole page bestie, you ate that, now go write a worker and register some functions. mwah. π
β¨π
π¦ where this page comes from
- ubuntu resolute: libgearman-dev 1.1.21+ds-1ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libgearman-dev 1.1.21+ds-1ubuntu3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms