1
.TH "GEARMAN_EXECUTE" "3" "September 14, 2012" "0.38" "Gearmand"
3
gearman_execute \- Gearmand Documentation, http://gearman.info/
5
.nr rst2man-indent-level 0
9
level \\n[rst2man-indent-level]
10
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
17
.\" .rstReportMargin pre:
19
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20
. nr rst2man-indent-level +1
21
.\" .rstReportMargin post:
25
.\" indent \\n[an-margin]
26
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27
.nr rst2man-indent-level -1
28
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
31
.\" Man page generated from reStructeredText.
35
#include <libgearman/gearman.h>
38
.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)
42
.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)
48
\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.
50
\fBgearman_work_t\fP can be used to describe the work that will be
51
executed, it is built with \fBgearman_argument_make()\fP. The argument
52
unique_str is optional, but if supplied it is used for coalescence by
55
\fBgearman_argument_t\fP is the work that the \fIclient\fP will send
58
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.
60
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.
62
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.
64
The result can be obtained from the task by calling
65
\fBgearman_task_result()\fP to gain the \fBgearman_result_st\fP.
68
\fI\%gearman_execute()\fP returns a c:type:\fIgearman_task_st\fP.
74
Example code to show how to send a string to a function called "reverse" and print the results.
78
# Gearman server and library
79
# Copyright (C) 2012 Data Differential, http://datadifferential.com/
80
# All rights reserved.
82
# Use and distribution licensed under the BSD license. See
83
# the COPYING file in this directory for full text.
89
#include <libgearman/gearman.h>
93
gearman_client_st *client= gearman_client_create(NULL);
95
gearman_return_t ret= gearman_client_add_server(client, "localhost", 0);
96
if (gearman_failed(ret))
101
gearman_argument_t value= gearman_argument_make(0, 0, "Reverse Me", strlen("Reverse Me"));
103
gearman_task_st *task= gearman_execute(client,
104
"reverse", strlen("reverse"), // function
105
NULL, 0, // no unique value provided
109
if (task == NULL) // If gearman_execute() can return NULL on error
111
fprintf(stderr, "Error: %s\en", gearman_client_error(client));
112
gearman_client_free(client);
116
// Make sure the task was run successfully
117
if (gearman_success(gearman_task_return(task)))
120
gearman_result_st *result= gearman_task_result(task);
121
printf("%.*s\en", (int)gearman_result_size(result), gearman_result_value(result));
124
gearman_client_free(client);
133
To find out more information please check:
134
\fI\%http://gearman.info/\fP
137
\fIgearmand(8)\fP \fIlibgearman(3)\fP
139
Data Differential http://www.datadifferential.com/
141
2012, Data Differential, http://www.datadifferential.com/
142
.\" Generated by docutils manpage writer.