1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
.TH "GEARMAN_EXECUTE" "3" "May 04, 2012" "0.33" "Gearmand"
.SH NAME
gearman_execute \- Gearmand Documentation, http://gearman.info/
.
.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
..
.\" Man page generated from reStructeredText.
.
.SH SYNOPSIS
.sp
#include <libgearman/gearman.h>
.INDENT 0.0
.TP
.B gearman_task_st *gearman_execute(gearman_client_st\fI\ *client\fP, const char\fI\ *function_name\fP, size_t\fI\ function_name_length\fP, const char\fI\ *unique\fP, size_t\fI\ unique_length\fP, gearman_work_t\fI\ *workload\fP, gearman_argument_t\fI\ *arguments\fP, void\fI\ *context\fP)
.UNINDENT
.INDENT 0.0
.TP
.B gearman_task_st *gearman_execute_by_partition(gearman_client_st\fI\ *client\fP, const char\fI\ *partition_function\fP, const size_t\fI\ partition_function_length\fP, const char\fI\ *function_name\fP, const size_t\fI\ function_name_length\fP, const char\fI\ *unique_str\fP, const size_t\fI\ unique_length\fP, gearman_work_t\fI\ *workload\fP, gearman_argument_t\fI\ *arguments\fP, void\fI\ *context\fP)
.UNINDENT
.sp
Link with \-lgearman
.SH DESCRIPTION
.sp
\fI\%gearman_execute()\fP is used to create a new \fBgearman_task_st\fP that is executed against the function that is found via the function_name argument.
.sp
\fBgearman_work_t\fP can be used to describe the work that will be
executed, it is built with \fBgearman_argument_make()\fP. The argument
unique_str is optional, but if supplied it is used for coalescence by
\fBgearmand\fP.
.sp
\fBgearman_argument_t\fP is the work that the \fIclient\fP will send
the to the server
.sp
If \fI\%gearman_execute()\fP is given a \fBgearman_work_t\fP that has been built with a reducer, it takes the \fBgearman_argument_t\fP and executs it against a \fIfunction\fP as it normally would, but it tells the function to then process the results through a \fIreducer\fP function that the \fBgearman_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 \fImapper\fP function will aggregate the work via an aggregator function, \fBgearman_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 \fBgearman_task_st\fP.
.sp
The result can be obtained from the task by calling
\fBgearman_task_result()\fP to gain the \fBgearman_result_st\fP.
.SH RETURN VALUE
.sp
\fI\%gearman_execute()\fP returns a c:type:\fIgearman_task_st\fP.
.SH EXAMPLE
.sp
.nf
.ft C
/*
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\en", 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\en", (int)gearman_result_size(result), gearman_result_value(result));
}
gearman_client_free(client);
return EXIT_SUCCESS;
}
.ft P
.fi
.SH HOME
.sp
To find out more information please check:
\fI\%http://gearman.info/\fP
.SH SEE ALSO
.sp
\fIgearmand(8)\fP \fIlibgearman(3)\fP
.SH AUTHOR
Data Differential http://www.datadifferential.com/
.SH COPYRIGHT
2012, Data Differential, http://www.datadifferential.com/
.\" Generated by docutils manpage writer.
.\"
.
|