.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "GEARMAN_EXECUTE" "3" "Jan 31, 2024" "1.1.20+ds" "Gearmand" .SH NAME gearman_execute \- Gearmand Documentation, http://gearman.info/ .SH SYNOPSIS .sp #include .INDENT 0.0 .TP .B \fI\%gearman_task_st\fP *gearman_execute(\fI\%gearman_client_st\fP *client, const char *function_name, \fI\%size_t\fP function_name_length, const char *unique, \fI\%size_t\fP unique_length, \fI\%gearman_work_t\fP *workload, \fI\%gearman_argument_t\fP *arguments, void *context) .UNINDENT .INDENT 0.0 .TP .B \fI\%gearman_task_st\fP *gearman_execute_by_partition(\fI\%gearman_client_st\fP *client, const char *partition_function, const \fI\%size_t\fP partition_function_length, const char *function_name, const \fI\%size_t\fP function_name_length, const char *unique_str, const \fI\%size_t\fP unique_length, \fI\%gearman_work_t\fP *workload, \fI\%gearman_argument_t\fP *arguments, void *context) .UNINDENT .sp Link with \-lgearman .SH DESCRIPTION .sp \fI\%gearman_execute()\fP is used to create a new \fI\%gearman_task_st\fP that is executed against the function that is found via the function_name argument. .sp \fI\%gearman_work_t\fP can be used to describe the work that will be executed, it is built with \fI\%gearman_argument_make()\fP\&. The argument unique_str is optional, but if supplied it is used for coalescence by \fBgearmand\fP\&. .sp \fI\%gearman_argument_t\fP is the work that the \fI\%client\fP will send the to the server .sp If \fI\%gearman_execute()\fP is given a \fI\%gearman_work_t\fP that has been built with a reducer, it takes the \fI\%gearman_argument_t\fP and executes it against a \fI\%function\fP as it normally would, but it tells the function to then process the results through a \fI\%reducer\fP function that the \fI\%gearman_work_t\fP was created with. .sp 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 \fI\%mapper\fP function will aggregate the work via an aggregator function, \fI\%gearman_aggregator_fn\fP, and return a result. .sp If any of the units of work error, the job will be aborted. The resulting value will be stored in the \fI\%gearman_task_st\fP\&. .sp The result can be obtained from the task by calling \fI\%gearman_task_result()\fP to gain the \fI\%gearman_result_st\fP\&. .SH RETURN VALUE .sp \fI\%gearman_execute()\fP returns a c:type:\fIgearman_task_st\fP\&. .SH EXAMPLE .INDENT 0.0 .INDENT 3.5 .sp .EX /* Example code to show how to send a string to a function called \(dqreverse\(dq and print the results. */ /* # 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 #include #include #include int main(void) { gearman_client_st *client= gearman_client_create(NULL); gearman_return_t ret= gearman_client_add_server(client, \(dqlocalhost\(dq, 0); if (gearman_failed(ret)) { return EXIT_FAILURE; } gearman_argument_t value= gearman_argument_make(0, 0, \(dqReverse Me\(dq, strlen(\(dqReverse Me\(dq)); gearman_task_st *task= gearman_execute(client, \(dqreverse\(dq, strlen(\(dqreverse\(dq), // function NULL, 0, // no unique value provided NULL, &value, 0); if (task == NULL) // If gearman_execute() can return NULL on error { fprintf(stderr, \(dqError: %s\en\(dq, 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(\(dq%.*s\en\(dq, (int)gearman_result_size(result), gearman_result_value(result)); } gearman_client_free(client); return EXIT_SUCCESS; } .EE .UNINDENT .UNINDENT .SH HOME .sp To find out more information please check: \fI\%http://gearman.info/\fP .SH SEE ALSO .sp \fBgearmand(8)\fP \fBlibgearman(3)\fP .SH AUTHOR Data Differential http://www.datadifferential.com/ .SH COPYRIGHT 2011-2024, Data Differential, http://www.datadifferential.com/ .\" Generated by docutils manpage writer. .