GEARMAN_WORKER_ADD_FUNCTION(3)

πŸ’– GEARMAN_WORKER_ADD_FUNCTION πŸ’–

okay bestie, sit DOWN, because this is libgearman's worker page β€” gearmand manual, section 3 β€” and it's literally the whole worker side of the party. it's giving "everything you need to talk to the server as a worker". no cap. 🫢


✨ 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 when you build, you link it like this:

-lgearman

periodt. ✨


🌸 DESCRIPTION 🌸

gearman_worker_st is the whole vibe for worker communication with the server. it's literally the thing that talks to gearmand for you, bestie.

gearman_worker_context() and gearman_worker_set_context() are your lil storage locker β€” you can stash an arbitrary object in there for the user, and get it back whenever. iconic for keeping your own state around. πŸŽ€

gearman_worker_set_task_context_free_fn() sets up a trigger β€” that trigger gets called when a gearman_task_st is released. it's giving cleanup crew energy. πŸ’…

gearman_worker_timeout() and gearman_worker_set_timeout() get and set the current timeout value for the worker. and heads up β€” that value is in milliseconds. 😌

gearman_worker_function_exist() is your little detective πŸ•΅οΈ β€” it tells you whether a given worker has a specific function.

gearman_worker_work() makes the worker execute against jobs until an error occurs. so it just goes and goes and goes. main character energy fr fr.

gearman_worker_grab_job() takes a job from one of the job servers. and listen β€” it's the responsibility of the caller to free the job once they are done with it. don't leave it hanging, that's a memory leak bestie 😭. also, lowkey important: this interface is used in testing, and is very rarely the correct interface to program against. so like… know that before you commit. πŸ’€

sooo, normally malloc(3) and free(3) are what get used for allocating and releasing workloads. but if you want your own custom moment, gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn() let you replace those with custom functions. bring your own allocator, slay. πŸ”₯

and if you need to remove a function from the server, you've got options, queen:

  1. call gearman_worker_unregister_all() to remove all functions that the worker has told the gearmand server about β€” the full clearout, nuke it from orbit πŸ’…
  2. or use gearman_worker_unregister() to remove just a single function β€” surgical, precise, obsessed

πŸ‘‘ RETURN πŸ‘‘

Various

(yeah, that's the whole section. it's giving mystery. it's giving "read the individual function pages". iykyk 🌈)


πŸ¦‹ 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 a wrap bestie!! this absolute queen of a page came to you from 1.1.21+ds, dated Feb 04, 2026, section GEARMAN_WORKER_ADD_FUNCTION(3) of the Gearmand manual. go forth and register your functions πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from