GEARMAN_CLIENT_DO_HIGH_BACKGROUND(3)

πŸ’– gearman_client_do_high_background(3) πŸ’–

okay bestie, sit down, hydrate, and let's talk about the third section of the manual: gearman_client_do_high_background β€” the gearmand girly who serves the docs at http://gearman.info/ ✨


πŸŽ€ NAME πŸŽ€

gearman_client_do_high_background β€” it's the Gearmand Documentation, and the whole vibe lives at http://gearman.info/ πŸ’…


🌸 SYNOPSIS 🌸

first things first, you gotta pull in the header, no cap:

#include <libgearman/gearman.h>

and there's this type hanging around:

type gearman_priority_t

then the plain background queen:

gearman_return_t gearman_client_do_background(gearman_client_st *client,
                                              const char *function_name,
                                              const char *unique,
                                              const void *workload,
                                              size_t workload_size,
                                              char *job_handle)
lowkey a glow-up happened in version 0.21: GEARMAN_PAUSE will no longer be returned. A do operation now runs until it has been submitted. periodt. πŸ¦‹

and here's our girl, the high-priority one, main character energy fr fr:

gearman_return_t gearman_client_do_high_background(gearman_client_st *client,
                                                   const char *function_name,
                                                   const char *unique,
                                                   const void *workload,
                                                   size_t workload_size,
                                                   gearman_job_handle_t job_handle)

and her low-priority sister, she's iconic too:

gearman_return_t gearman_client_do_low_background(gearman_client_st *client,
                                                  const char *function_name,
                                                  const char *unique,
                                                  const void *workload,
                                                  size_t workload_size,
                                                  gearman_job_handle_t job_handle)

✨ DESCRIPTION ✨

so gearman_client_do_background() does one single request to the gearmand server and hands you back the status through gearman_return_t πŸ’« one request, one status, that's the whole plot.

now, gearman_client_add_task_high_background() and gearman_client_add_task_low_background() are literally identical to gearman_client_do_background() β€” the only difference is they set the gearman_priority_t to either high or low. same girl, different energy level πŸ”₯

if job_handle is not NULL, it's gonna get populated with the name of the job_handle for the task that got created. and bestie, listen: the job handle needs to be the size of GEARMAN_JOB_HANDLE_SIZE. no skimping on the buffer, she needs her space. please see gearman_job_handle_t for more information 🫢


πŸ’œ RETURN VALUE πŸ’œ

gearman_return_t β€” that's it, that's the return. that's what you're getting back.


🌈 EXAMPLE 🌈

here's the whole thing, copy it exactly, don't be weird about it:

/*
# Gearman server and library
# Copyright (C) 2012 Data Differential, http://datadifferential.com/
# All rights reserved.
#
# Use and distribution licensed under the BSD license.  See
# the COPYING file in this directory for full text.
*/

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <libgearman-1.0/gearman.h>

int main(void)
{
  gearman_client_st *client= gearman_client_create(NULL);

  gearman_return_t ret= gearman_client_add_server(client, "localhost", 0);
  if (gearman_failed(ret))
  {
    return EXIT_FAILURE;
  }

  gearman_job_handle_t job_handle;
  gearman_return_t rc= gearman_client_do_background(client,
                                                    "reverse_function",
                                                    "unique_value",
                                                    "my string to reverse", strlen("my string to reverse"),
                                                    job_handle);

  if (gearman_success(rc))
  {
    // Make use of value
    printf("%s\n", job_handle);
  }

  gearman_client_free(client);

  return 0;
}

🏠 HOME 🏠

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

See also:


πŸ‘‘ Author πŸ‘‘

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


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


aaaand that's the whole page, bestie πŸŽ€ it's running version 1.1.21+ds, dated Feb 04 β€” go forth, submit your background jobs, and slay πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from