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()andgearman_job_send_fail()cannot be used with any functions created withgearman_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/>
π Copyright
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
- ubuntu resolute: libgearman-dev 1.1.21+ds-1ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libgearman-dev 1.1.21+ds-1ubuntu3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms