GEARMAN_WORKER_ST(3)
β¨ NAME β¨
gearman_worker_st β the worker-side vibe of libgearman, brought to you by the Gearmand docs over at <http://gearman.info/> π«Ά
So bestie, this is the section-3 manual page for gearman_worker_st, and it's literally the whole worker API in one place. Buckle up. π
π 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 *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_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)
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_work(gearman_worker_st *worker)
gearman_job_st *gearman_worker_grab_job(gearman_worker_st *worker, gearman_job_st *job, gearman_return_t *ret_ptr)
Link with -lgearman
And when you build, you link with -lgearman. Do not forget that part or the linker will simply pass away. β°οΈ
π DESCRIPTION π
gearman_worker_st is the struct for worker communication with the server. That's it, that's the whole deal β this is how a worker talks to gearmand.
Here's what each lil guy does, okay?
gearman_worker_context()andgearman_worker_set_context()let you store an arbitrary object for the user. Yours, your data, your rules. β¨gearman_worker_set_task_context_free_fn()sets a trigger that will be called when agearman_task_stis released. Cleanup on aisle task, so to speak.gearman_worker_timeout()andgearman_worker_set_timeout()get and set the current timeout value, in milliseconds, for the worker. Milliseconds, babe. Not seconds. Milliseconds.gearman_worker_function_exist()is used to determine if a given worker has a specific function. Yes/no energy.gearman_worker_work()has the worker execute against jobs until an error occurs. It just keeps going and going until something goes wrong. Main character energy, honestly.gearman_worker_grab_job()takes a job from one of the job servers. π«³β¨ Heads up though: it is the responsibility of the caller to free the job once they are done. And like β this interface is used in testing, and is very rarely the correct interface to program against. So if you're reaching for this in prod, bestie, maybe don't. π- Normally
malloc(3)andfree(3)handle allocation and releasing workloads. Butgearman_worker_set_workload_malloc_fn()andgearman_worker_set_workload_free_fn()let you replace these with custom functions. Bespoke allocation, we love to see it. - If you need to remove a function from the server, you've got two doors:
gearman_worker_unregister_all()β removes all functions that the worker has told the gearmand server about. All of them. Every single one.gearman_worker_unregister()β removes just a single function. Surgical. π
π₯ RETURN π₯
Various
(That's literally what it says. Various. Iconic of them honestly. π)
π HOME π
Want the full lore? Please check: <http://gearman.info/>
β SEE ALSO β
π¦ Author π¦
Data Differential <http://www.datadifferential.com/>
πΈ Copyright πΈ
2011-2014, Data Differential, http://www.datadifferential.com/
Shoutout to the footer crew: this page is from version1.1.21+ds, datedFeb 04, 2026, and it lives in the Gearmand docs. Stay slay,GEARMAN_WORKER_ST(3)stans. ππ
π¦ 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