GEARMAN_CLIENT_SERVER_SELECTION_BY_UNIQUE(3)
πΈ NAME πΈ
gearman_client_server_selection_by_unique β this is a page from the Gearmand manual, section 3, and the official docs live over at https://gearman.org/gearmand/ β¨
π¦ SYNOPSIS π¦
#include <libgearman/gearman.h>
void gearman_client_set_server_selection_by_unique(gearman_client_st *client, bool enable)
bool gearman_client_server_selection_by_unique(const gearman_client_st *client)
π DESCRIPTION π
Okay so picture this, bestie: by default, when a client has more than one server added via gearman_client_add_server() and it submits a job, that job gets sent to the first idle server in the order the servers were added. That's it. That's the whole vibe check. The job's unique identifier plays no part in the choice at all π
gearman_client_set_server_selection_by_unique() is the glow-up π«Ά β it opts a client into choosing the destination server by hashing the job's unique</> instead, using a ketama consistent-hash ring built from the client's current server list. The practical effect, and this is the iconic part: submissions sharing the same unique (whether they come from this client, or from any other client configured with the same server list and this option enabled) consistently land on the same server π
Adding or removing a server only reshuffles the jobs that server itself was responsible for. No mass chaos. No full re-shuffle. We love a stable ring ngl π
Heads up: this only affects job submission β that'sgearman_client_do(),gearman_client_do_background(), and their variants, plusgearman_client_add_task()and friends. Commands like status lookups are unaffected and just do their own thing. Also: a job submitted with an empty unique falls back to the default selection, since there's literally no meaningful value to hash π
If the hash-selected server can't be reached, the client fails over to the next server in ring order rather than failing the submission outright β same energy as how the default selection falls through the server list on a connection failure πβ¨
This option is disabled by default. You can also flip it on or off with the GEARMAN_CLIENT_SERVER_SELECTION_BY_UNIQUE flag via gearman_client_add_options() / gearman_client_remove_options() β and peek at it with gearman_client_has_option(). That route is highkey useful for language bindings that pass an options bitmask straight through to libgearman π§ Both ways change the same setting, no cap. And it's copied by gearman_client_clone() just like the client's other persistent settings π
gearman_client_server_selection_by_unique() tells you whether the option is currently enabled. That's the whole vibe π
β RETURN VALUE β
gearman_client_server_selection_by_unique() returns a bool. And yes, it returns false for a NULL client π«Ά (no crashing, we're polite here)
π HOME π
Want the full lore? To find out more information please check: https://gearman.org/gearmand/ π
SEE ALSO:
gearmand(8)libgearman(3)gearman_client_stgearman_client_add_server
π AUTHOR π
Data Differential β http://www.datadifferential.com/ π
πΈ COPYRIGHT πΈ
2011-2014, Data Differential, http://www.datadifferential.com/ π¦
and that's the page, bestie πβ¨ β brought to you by Gearmand version 2.2.0, dated Oct 18, 20, straight from the manual. go forth and hash responsibly ππ
π¦ where this page comes from
- arch rolling: gearmand 2.2.0-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms