GEARMAN_WORKER_DEFINE_FUNCTION(3)

✨ GEARMAN_WORKER_DEFINE_FUNCTION ✨

okay bestie, welcome to the Gearmand section 3 girlies πŸ’– this is gearman_worker_define_function and she is, lowkey, the moment.


🌸 NAME 🌸

gearman_worker_define_function β€” it's giving Gearmand Documentation, and the docs live at <http://gearman.info/>


πŸŽ€ SYNOPSIS πŸŽ€

#include <libgearman/gearman.h>

type gearman_function_t

gearman_return_t gearman_worker_define_function(gearman_worker_st *worker,
const char *function_name, const size_t function_name_length,
const gearman_function_t function, const uint32_t timeout, void *context)

type gearman_function_fn

type gearman_aggregator_fn

Link with -lgearman

πŸ’… DESCRIPTION πŸ’…

so gearman_worker_define_function() defines functions for a worker. that's the whole vibe. that's the job. πŸ‘‘

the interface is callback by design, no cap. when the server has a job for the worker, gearman_function_fn gets evoked β€” yes, evoked, she's summoned β€” with a gearman_job_st representing the job, plus the context that was defined originally when the function was defined. the context comes back to you like a boomerang. πŸͺƒ

results get sent back to the client by invoking gearman_job_send_data().

if the client specified a reducer function, then the output of gearman_function_fn will be sent to that function. and you can split the work out to the reducer function by sending data multiple times with gearman_job_send_data(). multiple sends, one reducer, it's a whole choreography. ✨

if any errors are detected then the entire job is cancelled 😭 the gearman_aggregator_fn will be called when all mapped jobs have completed. and the result of this function will be what is returned to the client. like, that's the final answer the client receives.

the callback function needs to return one of the following errors:

  • GEARMAN_SUCCESS β€” the function was successful. slay, no notes. πŸ’–
  • GEARMAN_FAIL β€” an error has occurred, the job we not processed, and the worker cannot continue. this is the bad one, bestie. 🚫
  • GEARMAN_ERROR β€” a transient error has occurred, like a network failure, and the job can be restarted. so like, we try again. πŸ™ˆ

if a value other then the above are returned it is converted to a GEARMAN_FAIL and gearman_worker_work() returns GEARMAN_INVALID_ARGUMENT. so like, don't be creative with your return values. she will notice. πŸ’€

⚠️ also super important: gearman_job_send_complete() and gearman_job_send_fail() cannot be used with any functions created with gearman_worker_define_function(). not compatible. they will not work. do not attempt. periodt. πŸ™…β€β™€οΈ

⭐ RETURN VALUE ⭐

gearman_return_t


πŸ¦‹ HOME πŸ¦‹

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


🌈 SEE ALSO 🌈

gearmand(8) libgearman(3) gearman_strerror(3) gearman_client_error gearman_client_execute_reduce


πŸ‘‘ Author

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

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


and that's the whole page, bestie 🫢 this was Gearmand version 1.1.21+ds, dated Feb 04, 2026 β€” so if you ever need the receipts, that's where she came from. iykyk πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from