gearman_execute man page on Fedora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Fedora logo
[printable version]

GEARMAN_EXECUTE(3)		   Gearmand		    GEARMAN_EXECUTE(3)

NAME
       gearman_execute - Gearmand Documentation, http://gearman.info/

SYNOPSIS
       #include <libgearman/gearman.h>

       gearman_task_st	  *gearman_execute(gearman_client_st *client,	 const
       char *function_name, size_t function_name_length,  const	 char *unique,
       size_t unique_length,	  gearman_work_t *workload,	 gearman_argu‐
       ment_t *arguments, void *context)

       gearman_task_st			   *gearman_execute_by_partition(gear‐
       man_client_st *client,	  const	    char *partition_function,	 const
       size_t partition_function_length,  const	  char *function_name,	 const
       size_t function_name_length,	 const	   char *unique_str,	 const
       size_t unique_length,	  gearman_work_t *workload,	 gearman_argu‐
       ment_t *arguments, void *context)

       Link with -lgearman

DESCRIPTION
       gearman_execute()  is used to create a new gearman_task_st that is exe‐
       cuted against the function that is found via  the  function_name	 argu‐
       ment.

       gearman_work_t  can be used to describe the work that will be executed,
       it is built with gearman_argument_make().  The argument	unique_str  is
       optional, but if supplied it is used for coalescence by gearmand.

       gearman_argument_t  is  the  work  that the client will send the to the
       server

       If gearman_execute() is given a gearman_work_t that has been built with
       a  reducer,  it	takes  the gearman_argument_t and executs it against a
       function as it normally would,  but  it	tells  the  function  to  then
       process	the results through a reducer function that the gearman_work_t
       was created with.

       What is happening is that the function is  mappping/splitting  work  up
       into units, and then sending each of them to the reducer function. Once
       all work is completed, the mapper function will aggregate the work  via
       an aggregator function, gearman_aggregator_fn, and return a result.

       If any of the units of work error, the job will be aborted. The result‐
       ing value will be stored in the gearman_task_st.

       The  result  can	 be  obtained  from  the   task	  by   calling	 gear‐
       man_task_result() to gain the gearman_result_st.

RETURN VALUE
       gearman_execute() returns a c:type:gearman_task_st.

EXAMPLE
       /*
	 Example code to show how to send a string to a function called "reverse" and print the results.
       */

       #include <string.h>
       #include <stdlib.h>
       #include <stdio.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;
	 }

	 gearman_argument_t value= gearman_argument_make(0, 0, "Reverse Me", strlen("Reverse Me"));

	 gearman_task_st *task= gearman_execute(client,
						"reverse", strlen("reverse"),  // function
						NULL, 0,  // no unique value provided
						NULL,
						&value, 0);

	 if (task == NULL) // If gearman_execute() can return NULL on error
	 {
	   fprintf(stderr, "Error: %s\n", gearman_client_error(client));
	   gearman_client_free(client);
	   return EXIT_FAILURE;
	 }

	 // Make sure the task was run successfully
	 if (gearman_success(gearman_task_return(task)))
	 {
	   // Make use of value
	   gearman_result_st *result= gearman_task_result(task);
	   printf("%.*s\n", (int)gearman_result_size(result), gearman_result_value(result));
	 }

	 gearman_client_free(client);

	 return EXIT_SUCCESS;
       }

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

SEE ALSO
       gearmand(8) libgearman(3)

AUTHOR
       Data Differential http://datadifferential.com/

COPYRIGHT
       2011, Data Differential, http://datadifferential.com/

0.23				 June 29, 2011		    GEARMAN_EXECUTE(3)
[top]

List of man pages available for Fedora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net