Browse Source

Fix a valgrind issue in the tests, and switch the design over for gearman_worker_define_function().

Brian Aker 13 years ago
parent
commit
9fd2ff4e09

+ 1 - 0
docs/conf.py.in

@@ -329,6 +329,7 @@ man_pages = [
   ('libgearman/gearman_worker_create', 'gearman_worker_clone', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),
   ('libgearman/gearman_worker_create', 'gearman_worker_create', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),
   ('libgearman/gearman_worker_create', 'gearman_worker_free', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),
+  ('libgearman/gearman_worker_define_function', 'gearman_worker_define_function', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),
   ('libgearman/gearman_worker_error', 'gearman_worker_errno', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),
   ('libgearman/gearman_worker_error', 'gearman_worker_error', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),
   ('libgearman/gearman_worker_options', 'gearman_worker_add_options', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://datadifferential.com/'], 3),

+ 1 - 0
docs/include.am

@@ -126,6 +126,7 @@ man_MANS+= \
 	   docs/man/gearman_worker_clone.3 \
 	   docs/man/gearman_worker_context.3 \
 	   docs/man/gearman_worker_create.3 \
+	   docs/man/gearman_worker_define_function.3 \
 	   docs/man/gearman_worker_echo.3 \
 	   docs/man/gearman_worker_errno.3 \
 	   docs/man/gearman_worker_error.3 \

+ 1 - 1
docs/index.rst

@@ -90,7 +90,7 @@ Worker Functions
    libgearman/gearman_worker_add_server
    libgearman/gearman_worker_options
    libgearman/gearman_worker_add_function
-   libgearman/gearman_worker_add_map_function
+   libgearman/gearman_worker_define_function
    libgearman/gearman_worker_error
    libgearman/gearman_worker_set_log_fn
 

+ 3 - 5
docs/libgearman/gearman_execute_map_reduce.rst

@@ -11,25 +11,23 @@ SYNOPSIS
 
 .. c:function:: gearman_task_st *gearman_execute_map_reduce(gearman_client_st *client, const char *mapper_name, const size_t mapper_length, const char *reducer_name, const size_t reducer_length, const char *unique_str, const size_t unique_length, gearman_work_t *workload, gearman_argument_t *arguments);
 
-.. c::type typedef gearman_worker_error_t (gearman_mapper_fn)(gearman_job_st *job, void *context);
-
 Link with -lgearman
 
 -----------
 DESCRIPTION
 -----------
 
-gearman_client_execute_reduce() takes a given :c:type::`gearman_argument_t` and executs it against a :c:type::`gearman_mapper_fn` function. This function is specified via the 
+gearman_client_execute_reduce() takes a given :c:type:`gearman_argument_t` and executs it against a :c:type:`gearman_mapper_fn` function. This function is specified via the 
 mapper_name argument. The mapper function will then break the work up into units, and send each of them to the function named reducer function. Once all work is completed, the mapper function will aggregate the work and return a result.
 
-If any of the units of work error, the job will be aborted. The resulting value will be stored in the :c:type::`gearman_task_st`.
+If any of the units of work error, the job will be aborted. The resulting value will be stored in the :c:type:`gearman_task_st`.
 
 
 ------------
 RETURN VALUE
 ------------
 
-gearman_client_execute_reduce() returns a pointer to a gearman_task_st. On error a NULL will be returned. The error can be examined with c:function::`gearman_client_error()`.
+:c:func:`gearman_client_execute_reduce()` returns a pointer to a :c:type:`gearman_task_st`. On error a NULL will be returned. The error can be examined with :c:func:`gearman_client_error()`.
 
 ----
 HOME

+ 0 - 64
docs/libgearman/gearman_worker_add_map_function.rst

@@ -1,64 +0,0 @@
-============================================
-Creating a worker to handle a map/reduce job 
-============================================
-
---------
-SYNOPSIS
---------
-
-#include <libgearman/gearman.h>
-
-.. c:function:: gearman_return_t gearman_worker_add_map_function(gearman_worker_st *worker, const char *function_name, size_t functiona_name_length, uint32_t timeout, gearman_mapper_fn *mapper_function, gearman_aggregator_fn *aggregator_function, void *context)
-
-.. c::type:: gearman_worker_error_t (gearman_mapper_fn)(gearman_job_st *job, void *context)
-
-.. c::type:: gearman_return_t (gearman_aggregator_fn)(gearman_aggregator_st *, gearman_task_st *, gearman_result_st *)
-
-Link with -lgearman
-
------------
-DESCRIPTION
------------
-
-:c:func:`gearman_worker_add_map_function()` creates a worker that will be
-used to execute jobs created by :c:type:`gearman_client_execute_reduce()`.
-:c:type:`gearman_mapper_fn` are passed a job and will need to return
-a :c:type:`gearman_worker_error_t` upon exit.  For each call of
-:c:func:`gearman_job_send_data()` a :c:type:`gearman_job_st` is created. 
-
-Each job will be executed against the aggregate function that
-:c:type:`gearman_client_execute_reduce()` specified. If any errors are
-detected then the entire job is cancelled.  The gearman_aggregator_fn will
-be called when all mapped jobs have completed. The result of this function
-will be what is returned to the client.
-
-The callback function needs to populute the ret value with one of the following errors:
-
-:c:type:`GEARMAN_WORKER_SUCCESS`
-
-:c:type:`GEARMAN_WORKER_FAIL`
-
-:c:func:`gearman_job_send_complete()` and :c:func:`gearman_job_send_fail()` cannot be used with mapper functions.
-
-------------
-RETURN VALUE
-------------
-
-:c:type:`gearman_return_t`
-
-----
-HOME
-----
-
-
-To find out more information please check:
-`https://launchpad.net/gearmand <https://launchpad.net/gearmand>`_
-
-
---------
-SEE ALSO
---------
-
-:manpage:`gearmand(8)` :manpage:`libgearman(3)` :manpage:`gearman_strerror(3)` :manpage:`gearman_client_error` :manpage:`gearman_client_execute_reduce`
-
-

+ 64 - 0
docs/libgearman/gearman_worker_define_function.rst

@@ -0,0 +1,64 @@
+======================================================
+Creating workers with gearman_worker_define_function()
+======================================================
+
+--------
+SYNOPSIS
+--------
+
+#include <libgearman/gearman.h>
+
+.. c:function:: gearman_return_t gearman_worker_define_function(gearman_worker_st *worker, const char *function_name, const size_t function_name_length, const gearman_function_t function, const uint32_t timeout, void *context)
+
+.. c:type:: gearman_function_fn
+
+.. c:type:: gearman_aggregator_fn
+
+Link with -lgearman
+
+-----------
+DESCRIPTION
+-----------
+
+:c:func:`gearman_worker_define_function()` defines functions for a worker.
+
+The interface is callback by design. When the server has a job for the worker, :c:type:`gearman_function_fn` is evoked with a :c:type:`gearman_job_st` representing the job, and the context that was defined originally when the function was defined.
+
+Results are sent back to the client by invoking :c:func:`gearman_job_send_data()`.
+
+If the client specified an reducer function, then the output of the :c:type:`gearman_function_fn` will be sent to that function. You can split the work out to the reducer function by sending data multiple times with :c:func:`gearman_job_send_data()`.
+
+If any errors are detected then the entire job is cancelled.  The :c:type:`gearman_aggregator_fn` will
+be called when all mapped jobs have completed. The result of this function
+will be what is returned to the client. 
+
+The callback function needs to return one of the following errors:
+
+:c:type:`GEARMAN_WORKER_SUCCESS`
+
+:c:type:`GEARMAN_WORKER_FAIL`
+
+:c:func:`gearman_job_send_complete()` and :c:func:`gearman_job_send_fail()` cannot be used with any functions created with :c:func:`gearman_worker_define_function()`.
+
+------------
+RETURN VALUE
+------------
+
+:c:type:`gearman_return_t`
+
+----
+HOME
+----
+
+
+To find out more information please check:
+`https://launchpad.net/gearmand <https://launchpad.net/gearmand>`_
+
+
+--------
+SEE ALSO
+--------
+
+:manpage:`gearmand(8)` :manpage:`libgearman(3)` :manpage:`gearman_strerror(3)` :manpage:`gearman_client_error` :manpage:`gearman_client_execute_reduce`
+
+

+ 1 - 1
docs/man/gearadmin.1

@@ -1,4 +1,4 @@
-.TH "GEARADMIN" "1" "June 13, 2011" "0.21" "Gearmand"
+.TH "GEARADMIN" "1" "June 14, 2011" "0.21" "Gearmand"
 .SH NAME
 gearadmin \- Gearmand Documentation, http://gearman.info/
 .

+ 1 - 1
docs/man/gearman.1

@@ -1,4 +1,4 @@
-.TH "GEARMAN" "1" "June 13, 2011" "0.21" "Gearmand"
+.TH "GEARMAN" "1" "June 14, 2011" "0.21" "Gearmand"
 .SH NAME
 gearman \- Gearmand Documentation, http://gearman.info/
 .

+ 1 - 1
docs/man/gearman_actions_t.3

@@ -1,4 +1,4 @@
-.TH "GEARMAN_ACTIONS_T" "3" "June 13, 2011" "0.21" "Gearmand"
+.TH "GEARMAN_ACTIONS_T" "3" "June 14, 2011" "0.21" "Gearmand"
 .SH NAME
 gearman_actions_t \- Gearmand Documentation, http://gearman.info/
 .

+ 1 - 1
docs/man/gearman_bugreport.3

@@ -1,4 +1,4 @@
-.TH "GEARMAN_BUGREPORT" "3" "June 13, 2011" "0.21" "Gearmand"
+.TH "GEARMAN_BUGREPORT" "3" "June 14, 2011" "0.21" "Gearmand"
 .SH NAME
 gearman_bugreport \- Gearmand Documentation, http://gearman.info/
 .

Some files were not shown because too many files changed in this diff