GEARMAN_WORKER_SET_CONTEXT(3)

✨ GEARMAN_WORKER_SET_CONTEXT ✨

okay so bestie, this is a libgearman man page, from the Gearmand docs over at http://gearman.info/ β€” and we're about to get into worker context, timeouts, workload allocators and all that good stuff. grab a strawberry πŸ“ and let's go.


🌸 NAME 🌸

gearman_worker_set_context β€” the Gearmand Documentation situation, http://gearman.info/


πŸ’… 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 yeah β€” you link it with -lgearman. don't forget that part, seriously, the linker will be so dramatic about it 😭


πŸ‘‘ DESCRIPTION πŸ‘‘

gearman_worker_st is the whole vibe for a worker talking to the server. like, that's its entire job. 🫢

gearman_worker_context() and gearman_worker_set_context() let you stash an arbitrary object for the user. whatever you want. it's your little pocket. πŸ’–

gearman_worker_set_task_context_free_fn() sets a trigger that gets called when a gearman_task_st <#c.gearman_task_st> is released. so it's the lil cleanup cue, iykyk.

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() is literally just used to figure out if a given worker has a specific function. yes/no. that's it. slay.

gearman_worker_work() has the worker just keep executing against jobs until an error occurs. it's giving main character energy that never clocks out. πŸ”₯

gearman_worker_grab_job() takes a job from one of the job servers. heads up: it is the responsibility of the caller to free the job once they're done β€” so don't just wander off. also, this interface is used in testing, and it is very rarely the correct interface to program against. like, genuinely. noted. πŸ’€

normally malloc(3) and free(3) handle allocation and releasing workloads. if you wanna switch that up, gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn() let you swap in your own custom functions. bespoke memory management, we love to see it. ✨

and if you need to remove a function from the server, you've got two options, pick your fighter:

  • gearman_worker_unregister_all() β€” removes all functions that the worker has told the gearmand server about.
  • gearman_worker_unregister() β€” removes just a single function.

πŸŽ€ RETURN πŸŽ€

Various. yeah. that's the whole thing. various. it's giving mystery, it's giving chaos, we move. πŸ¦‹


🌈 HOME 🌈

wanna find out more? go check: <http://gearman.info/> β€” that's the spot. ⭐


πŸ’œ 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 cap πŸ’– this lil guy was 1.1.21+ds, dated Feb 04, 2026, and it comes to you from the GEARMAN_WORKER_SET_CONTEXT(3) corner of the Gearmand manual. go set some context, periodt. πŸ‘‘

πŸ“¦ where this page comes from