LIBGEARMAN(3)

πŸ’– NAME πŸ’–

libgearman β€” it's the Gearmand documentation, bestie, and if you want the whole vibe in one place it lives at http://gearman.info/ ✨

psst β€” this page is libgearman(3) from the Gearmand manual. Now you know. πŸ’…

✨ SYNOPSIS ✨

#include <libgearman/gearman.h>

Link it up with:

-lgearman

🌸 DESCRIPTION 🌸

Gearman Client/Worker Library is a small, thread-safe client library for the gearman protocol 🫢 The code was written with an eye to allowing both web and embedded usage, which is iconic of it honestly. It handles all the work behind routing particular keys to the specific servers you specify β€” and heads up, values get matched based on the server order as supplied by you, so the ordering is on you, no cap. It implements both the client and worker interfaces.

Every operation you do gets performed against either a client β€” that's gearman_client_st β€” or a worker β€” that's gearman_worker_st. Two structures, one destiny πŸ’«

So like, Client and Worker structures can be dynamically allocated or statically allocated. Either way they must then be initialized by gearman_client_create() or gearman_worker_create(). Don't skip that step, it's giving "I forgot to press start" 😭

The functions were written to encapsulate all the structures in the library. So the recommendation, fr fr: do not operate directly against the structure. Stay in your lane, use the functions πŸŽ€

Nearly all functions return a gearman_return_t value, and you can turn that value into a printable string with gearman_strerror(). Super handy for when something goes sideways πŸ™ˆ

Okay so the important bit: gearman_client_st and gearman_worker_st structures are thread-safe, BUT each thread must contain its own structure β€” meaning if you wanna share these among threads you have to provide your own locking. And good news: no global variables are used in this library. Clean. Immaculate. 🌈

If you're working with GNU autotools, you'll want to add the following to your configure.ac so libgearman gets properly included in your application:

PKG_CHECK_MODULES(DEPS, libgearman >= 0.8.0) AC_SUBST(DEPS_CFLAGS) AC_SUBST(DEPS_LIBS)

Hope you enjoy it! πŸ₯ΉπŸ’–


πŸŽ€ CONSTANTS πŸŽ€

A number of constants have been provided for in the library, and they're all little gifts ✨

  • GEARMAN_DEFAULT_TCP_PORT β€” the default port used by gearmand(3). πŸ‘‘
  • GEARMAN_DEFAULT_TCP_PORT β€” the default service used by gearmand(3). Yes bestie, it's listed twice in the original, and we are keeping it that way. Periodt. πŸ’€
  • LIBGEARMAN_VERSION_STRING β€” the string value of the libgearman version, such as "0.20.4". 🏷️
  • LIBGEARMAN_VERSION_HEX β€” the hex value of the version number: "0x00048000". This one can be used for comparing versions based on number πŸ”’
  • GEARMAN_UNIQUE_SIZE β€” the largest number of characters that can be used for a unique value. πŸ“
  • GEARMAN_JOB_HANDLE_SIZE β€” the largest number of characters that will be used for a job handle. If you want the additional info, go peek at gearman_job_handle_t 🫢

🧚 THREADS AND PROCESSES 🧚

Listen up, this one matters: when you're using threads OR forked processes, it is important to keep an instance of gearman_client_st or gearman_worker_st per process or per thread. πŸ¦‹

Without creating your own locking structures, you can not share a single gearman_client_st or gearman_worker_st. That's the rule and she does not bend. πŸ’…

πŸ¦‹ HOME πŸ¦‹

To find out more information, please check:

https://github.com/gearman/gearmand

Go scroll, go vibe, go learn 🌸


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’œ Author πŸ’œ

Data Differential β€” http://www.datadifferential.com/


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


okay that's the whole page, bestie, and honestly? she ate πŸ”₯ shoutout to the Gearmand crew for version 1.1.21+ds, dated Feb 04, 2026 β€” go be the main character of your own build, mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from