GEARMAN_WORKER_SET_WORKLOAD_FREE_FN(3)

πŸ’– GEARMAN_WORKER_SET_WORKLOAD_FREE_FN πŸ’–

okay bestie, welcome to the Gearmand manual, section 3 β€” yes, the whole page is named after gearman_worker_set_workload_free_fn but it's lowkey a whole worker-era glow-up tour. pull up a chair, we're doing this together 🫢


✨ 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 literally do not forget to link with -lgearman, the way that the linker will absolutely ghost you otherwise 😭


🌸 DESCRIPTION 🌸

so gearman_worker_st is the whole moment for worker-side communication with the server. it's giving main character energy in the worker world πŸ’…

gearman_worker_context() and gearman_worker_set_context() are your little storage cubbies β€” you can stash an arbitrary object of your own in there and come back for it whenever. obsessed.

gearman_worker_set_task_context_free_fn() sets up a trigger (a callback, bestie) that gets called when a gearman_task_st <#c.gearman_task_st> is released. so like, cleanup time, but make it ✨your✨ cleanup.

gearman_worker_timeout() and gearman_worker_set_timeout() are a matching set: one gets, one sets, and the value they're playing with is the current timeout, measured in milliseconds, for the worker. get it, set it, slay.

gearman_worker_function_exist() β€” as the name fr fr suggests β€” tells you whether a given worker has a specific function. yes, it's spelled exist. no, we don't fix it. it's iconic that way πŸŽ€

gearman_worker_work() makes the worker just, like, execute against jobs until an error occurs. it's a marathon, not a sprint πŸ’€

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. also, this interface is used in testing, and it is very rarely the correct interface to program against β€” so ngl, if you're reaching for this in prod, vibe check yourself first πŸ™ˆ

normally malloc(3) and free(3) are the ones handling allocation and releasing of workloads. but if you want something custom, gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn() let you swap those out with your own functions. custom allocator? periodt.

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

  • 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

choose your fighter πŸ’–


πŸ¦‹ RETURN πŸ¦‹

Various. (no fr, that's what it says β€” the return values are unspecified and we are respecting the mystery 🧚)


🌈 HOME 🌈

want more tea, more lore, more everything? it's all waiting for you at <http://gearman.info/> β€” go drink it up bestie ⭐


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’œ Author

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

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


and that's the whole page, no cap πŸ’… sending you off with the classic footer energy: this was Gearmand 1.1.21+ds, dated Feb 04, and the manual page name up top is GEARMAN_WORKER...ORKLOAD_FREE_FN(3) because apparently we only had so many characters to spare. go forth, register your functions, free your workloads, and remember β€” you got this 🫢🌸

πŸ“¦ where this page comes from