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() and gearman_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 a gearman_task_st is released. Cleanup on aisle task, so to speak.
  • gearman_worker_timeout() and gearman_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) and free(3) handle allocation and releasing workloads. But gearman_worker_set_workload_malloc_fn() and gearman_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:
    1. gearman_worker_unregister_all() β€” removes all functions that the worker has told the gearmand server about. All of them. Every single one.
    2. 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/>


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


Shoutout to the footer crew: this page is from version 1.1.21+ds, dated Feb 04, 2026, and it lives in the Gearmand docs. Stay slay, GEARMAN_WORKER_ST(3) stans. πŸŽ€πŸ’œ
πŸ“¦ where this page comes from