Issuing a single request¶
SYNOPSIS¶
#include <libgearman/gearman.h>
-
void *gearman_client_do(gearman_client_st *client, const char *function_name, const char *unique, const void *workload, size_t workload_size, size_t *result_size, gearman_return_t *ret_ptr)¶
Changed in version 0.21: GEARMAN_PAUSE
will no longer be returned. A do operation will now run till completion or error.
-
void *gearman_client_do_high(gearman_client_st *client, const char *function_name, const char *unique, const void *workload, size_t workload_size, size_t *result_size, gearman_return_t *ret_ptr)¶
-
void *gearman_client_do_low(gearman_client_st *client, const char *function_name, const char *unique, const void *workload, size_t workload_size, size_t *result_size, gearman_return_t *ret_ptr)¶
DESCRIPTION¶
gearman_client_do()
executes a single request to the gearmand
server and waits for a reply.
gearman_client_do_high()
and gearman_client_do_low()
are
identical to gearman_client_do()
, only they set the priority to
either high or low.
All of the functions will block until either a response or an error is returned.
RETURN VALUE¶
gearman_client_do()
returns a pointer to a value that the caller must release. If ret_ptr is provided any errors that have occurred will be stored in it. Since a NULL/zero value is a valid value, you will always need to check ret_ptr if you are concerned with errors.
Example¶
/*
# 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 <libgearman/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;
}
size_t result_size;
gearman_return_t rc;
void *value= gearman_client_do(client, "reverse_function", "unique_value",
"my string to reverse", strlen("my string to reverse"),
&result_size, &rc);
if (gearman_success(rc))
{
// Make use of value
}
free(value);
gearman_client_free(client);
return 0;
}
HOME¶
To find out more information please check: http://gearman.info/
See also
gearmand(8) libgearman(3) gearman_strerror(3)