~fractalcat/gearmand/docfixes

« back to all changes in this revision

Viewing changes to docs/man/gearman_execute.3

  • Committer: Brian Aker
  • Date: 2012-09-30 23:55:03 UTC
  • mto: (621.4.21 workspace)
  • mto: This revision was merged to the branch mainline in revision 656.
  • Revision ID: brian@tangent.org-20120930235503-u6r0uq1hl0mdj5an
Fix it so that we don't need to store the manpages in the tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.TH "GEARMAN_EXECUTE" "3" "September 14, 2012" "0.38" "Gearmand"
2
 
.SH NAME
3
 
gearman_execute \- Gearmand Documentation, http://gearman.info/
4
 
.
5
 
.nr rst2man-indent-level 0
6
 
.
7
 
.de1 rstReportMargin
8
 
\\$1 \\n[an-margin]
9
 
level \\n[rst2man-indent-level]
10
 
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
11
 
-
12
 
\\n[rst2man-indent0]
13
 
\\n[rst2man-indent1]
14
 
\\n[rst2man-indent2]
15
 
..
16
 
.de1 INDENT
17
 
.\" .rstReportMargin pre:
18
 
. RS \\$1
19
 
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20
 
. nr rst2man-indent-level +1
21
 
.\" .rstReportMargin post:
22
 
..
23
 
.de UNINDENT
24
 
. RE
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
30
 
..
31
 
.\" Man page generated from reStructeredText.
32
 
.
33
 
.SH SYNOPSIS
34
 
.sp
35
 
#include <libgearman/gearman.h>
36
 
.INDENT 0.0
37
 
.TP
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)
39
 
.UNINDENT
40
 
.INDENT 0.0
41
 
.TP
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)
43
 
.UNINDENT
44
 
.sp
45
 
Link with \-lgearman
46
 
.SH DESCRIPTION
47
 
.sp
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.
49
 
.sp
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
53
 
\fBgearmand\fP.
54
 
.sp
55
 
\fBgearman_argument_t\fP is the work that the \fIclient\fP will send
56
 
the to the server
57
 
.sp
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.
59
 
.sp
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.
61
 
.sp
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.
63
 
.sp
64
 
The result can be obtained from the task by calling
65
 
\fBgearman_task_result()\fP to gain the \fBgearman_result_st\fP.
66
 
.SH RETURN VALUE
67
 
.sp
68
 
\fI\%gearman_execute()\fP returns a c:type:\fIgearman_task_st\fP.
69
 
.SH EXAMPLE
70
 
.sp
71
 
.nf
72
 
.ft C
73
 
/*
74
 
  Example code to show how to send a string to a function called "reverse" and print the results.
75
 
*/
76
 
 
77
 
/*
78
 
# Gearman server and library
79
 
# Copyright (C) 2012 Data Differential, http://datadifferential.com/
80
 
# All rights reserved.
81
 
#
82
 
# Use and distribution licensed under the BSD license.  See
83
 
# the COPYING file in this directory for full text.
84
 
*/
85
 
 
86
 
#include <string.h>
87
 
#include <stdlib.h>
88
 
#include <stdio.h>
89
 
#include <libgearman/gearman.h>
90
 
 
91
 
int main(void)
92
 
{
93
 
  gearman_client_st *client= gearman_client_create(NULL);
94
 
 
95
 
  gearman_return_t ret= gearman_client_add_server(client, "localhost", 0);
96
 
  if (gearman_failed(ret))
97
 
  {
98
 
    return EXIT_FAILURE;
99
 
  }
100
 
 
101
 
  gearman_argument_t value= gearman_argument_make(0, 0, "Reverse Me", strlen("Reverse Me"));
102
 
 
103
 
  gearman_task_st *task= gearman_execute(client, 
104
 
                                         "reverse", strlen("reverse"),  // function
105
 
                                         NULL, 0,  // no unique value provided
106
 
                                         NULL, 
107
 
                                         &value, 0);
108
 
 
109
 
  if (task == NULL) // If gearman_execute() can return NULL on error
110
 
  {
111
 
    fprintf(stderr, "Error: %s\en", gearman_client_error(client));
112
 
    gearman_client_free(client);
113
 
    return EXIT_FAILURE;
114
 
  }
115
 
 
116
 
  // Make sure the task was run successfully
117
 
  if (gearman_success(gearman_task_return(task)))
118
 
  {
119
 
    // Make use of value
120
 
    gearman_result_st *result= gearman_task_result(task);
121
 
    printf("%.*s\en", (int)gearman_result_size(result), gearman_result_value(result));
122
 
  }
123
 
 
124
 
  gearman_client_free(client);
125
 
 
126
 
  return EXIT_SUCCESS;
127
 
}
128
 
 
129
 
.ft P
130
 
.fi
131
 
.SH HOME
132
 
.sp
133
 
To find out more information please check:
134
 
\fI\%http://gearman.info/\fP
135
 
.SH SEE ALSO
136
 
.sp
137
 
\fIgearmand(8)\fP \fIlibgearman(3)\fP
138
 
.SH AUTHOR
139
 
Data Differential http://www.datadifferential.com/
140
 
.SH COPYRIGHT
141
 
2012, Data Differential, http://www.datadifferential.com/
142
 
.\" Generated by docutils manpage writer.
143
 
.\" 
144
 
.