GEARMAN_CLIENT_SET_DATA_FN(3)

πŸ’– GEARMAN_CLIENT_SET_DATA_FN πŸ’–

okay bestie, welcome to the Gearmand manual, section 3 β€” meaning it's a library-function page, iykyk. yes this page is named after gearman_client_set_data_fn but it's actually giving the whole callback-gang ✨


🌸 NAME 🌸

gearman_client_set_data_fn β€” that's the star of the show, but the docs here live at http://gearman.info/ 🫢


✨ SYNOPSIS ✨

First up, the includes, because you always gotta bring the right header to the function party:

#include <libgearman/gearman.h>

the types, bestie (yes all of them) πŸŽ€

type gearman_actions_t

type gearman_workload_fn

type gearman_created_fn

type gearman_data_fn

type gearman_warning_fn

type gearman_universal_status_fn

type gearman_exception_fn

type gearman_fail_fn

type gearman_complete_fn

the functions πŸ’…

void gearman_client_set_workload_fn(gearman_client_st *client, gearman_workload_fn *function)

void gearman_client_set_created_fn(gearman_client_st *client, gearman_created_fn *function)

void gearman_client_set_data_fn(gearman_client_st *client, gearman_data_fn *function)

void gearman_client_set_warning_fn(gearman_client_st *client, gearman_warning_fn *function)

void gearman_client_set_status_fn(gearman_client_st *client, gearman_universal_status_fn *function)

void gearman_client_set_complete_fn(gearman_client_st *client, gearman_complete_fn *function)

void gearman_client_set_exception_fn(gearman_client_st *client, gearman_exception_fn *function)

void gearman_client_set_fail_fn(gearman_client_st *client, gearman_fail_fn *function)

void gearman_client_clear_fn(gearman_client_st *client)

const char *gearman_client_do_job_handle(gearman_client_st *client)

Link to -lgearman β€” that's the librarian you're checking out, don't forget to link her. πŸ“š


πŸ¦‹ DESCRIPTION πŸ¦‹

So. These are callbacks for client execution task states. Basically: your client is doing a job, the job goes through ~vibes~ (states), and you get to plant a little function to run at each one. cute, right?

  • gearman_client_set_data_fn() β€” sets the callback that gets called when the server hits up the client like "bestie, give me more data pls". it's giving main character energy the way your code gets pulled back in for more. 😭
  • gearman_client_do_job_handle() β€” gets the job handle for the running task. the important thing: call this between repeated gearman_client_do() (and related) calls when you want to get info. it's a between-the-calls girlie, not a during-the-call one. ✨
  • gearman_client_clear_fn() β€” call this to remove all the existing gearman_actions_t that have been set. full reset, fresh start, glow-up moment πŸ’…

okay so now the big group chat: gearman_client_set_created_fn(), gearman_client_set_data_fn(), gearman_client_set_warning_fn(), gearman_client_set_status_fn(), gearman_client_set_complete_fn(), gearman_client_set_exception_fn(), and gearman_client_set_fail_fn() all set callback functions for the different states of execution for a client request. and here's the tea: each request β€” ie a creation of gearman_task_st β€” keeps a copy of the callbacks when it is created. so past-you's callback choices get snapshotted, no takebacksies 🫰

gearman_client_set_exception_fn() only gets called if exceptions are enabled on the server. and how do you do that? by calling gearman_client_set_server_option(). yes, that's the whole ritual.

An example of this:

const char *EXCEPTIONS="exceptions";
gearman_client_set_server_option(client, EXCEPTIONS, strlen(EXCEPTIONS));

slay. that's it. that's the example. 🧚


🌈 RETURN VALUE 🌈

None. nothing. void energy. the functions simply do the thing and hand you back zero receipts. πŸ’€

See also: gearmand(8) libgearman(3) gearman_client_error(3) or gearman_worker_error(3)


πŸ‘‘ Author πŸ‘‘

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

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


okay that's the whole page, bestie, you ate it up πŸ“ so this was version 1.1.21+ds, dated Feb 04, 2026, from the Gearmand corner of the universe β€” go forth and set those callbacks, no cap πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from