GEARMAN_WORKER_REGISTER(3)

πŸ’– GEARMAN_WORKER_REGISTER πŸ’–

okay bestie, gather round, because this is the gearmand manual page for GEARMAN_WORKER_REGISTER(3) and it is literally the blueprint for making your worker actually do stuff. no cap. 🫢


✨ NAME ✨

gearman_worker_register β€” the Gearmand Documentation, and yes it lives at <http://gearman.info/> 🌸


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta pull in the header, periodt:

#include <libgearman/gearman.h>

and here's the whole cast of characters, fr fr: πŸ‘‘

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 when you link it, you link it like this, don't forget it bestie:

Link with -lgearman

πŸ¦‹ DESCRIPTION πŸ¦‹

so gearman_worker_st is the whole vibe β€” it's what your worker uses to talk to the server. that's it, that's the friendship. πŸ’…

gearman_worker_context() and gearman_worker_set_context() let you stash an arbitrary object in there for the user. your stuff, your rules, keep it cozy. 🧺

gearman_worker_set_task_context_free_fn() sets a trigger that gets called when a gearman_task_st <#c.gearman_task_st> is released. like a lil cleanup fairy. 🧚

gearman_worker_timeout() and gearman_worker_set_timeout() get and set the current timeout value in milliseconds, for the worker. milliseconds bestie, not seconds, do not play yourself. ⏱️

gearman_worker_function_exist() tells you whether a given worker has a specific function. vibe check, but for functions. βœ…

gearman_worker_work() has the worker execute against jobs until an error occurs. it just keeps going, main character energy, until something goes wrong. 😭

gearman_worker_grab_job() takes a job from one of the job servers. and listen β€” it is the responsibility of the caller to free the job once they are done. that's on you. 🫡

not me being dramatic but: this interface is used in testing, and is very rarely the correct interface to program against. so like… know that going in. πŸ’€

normally malloc(3) and free(3) handle allocation and releasing workloads. but if you wanna be fancy, gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn() can replace those with custom functions. custom fit, tailored, iconic. ✨

and if you need to remove a function from the server, you've got two doors: call gearman_worker_unregister_all() to remove all functions that the worker has told the gearmand server about, or use gearman_worker_unregister() to remove just a single function. one at a time or the whole roster, your call. 🎯


🌈 RETURN 🌈

Various. (yes really, that's the whole thing. slay, i guess. πŸ’€)


🏠 HOME 🏠

to find out more information please check: <http://gearman.info/>


πŸ‘€ SEE ALSO πŸ‘€


πŸ’œ Author πŸ’œ

Data Differential <http://www.datadifferential.com/>

2011-2014, Data Differential, <http://www.datadifferential.com/>


and that's the whole page bestie, no notes. this was 1.1.21+ds, dated Feb 04, 2026, straight out of the Gearmand source β€” go forth and register those functions, you absolute icon. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from