gearman_execute.rst 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ==============
  2. Executing Work
  3. ==============
  4. --------
  5. SYNOPSIS
  6. --------
  7. #include <libgearman/gearman.h>
  8. .. c:function:: gearman_task_st *gearman_execute(gearman_client_st *client, const char *function_name, size_t function_name_length, const char *unique, size_t unique_length, gearman_work_t *workload, gearman_argument_t *arguments, void *context)
  9. .. c:function:: gearman_task_st *gearman_execute_by_partition(gearman_client_st *client, const char *partition_function, const size_t partition_function_length, const char *function_name, const size_t function_name_length, const char *unique_str, const size_t unique_length, gearman_work_t *workload, gearman_argument_t *arguments, void *context)
  10. Link with -lgearman
  11. -----------
  12. DESCRIPTION
  13. -----------
  14. :c:func:`gearman_execute` is used to create a new :c:type:`gearman_task_st` that is executed against the function that is found via the function_name argument.
  15. :c:type:`gearman_work_t` can be used to describe the work that will be
  16. executed, it is built with :c:func:`gearman_argument_make`. The argument
  17. unique_str is optional, but if supplied it is used for coalescence by
  18. :program:`gearmand`.
  19. :c:type:`gearman_argument_t` is the work that the :term:`client` will send
  20. the to the server
  21. If :c:func:`gearman_execute` is given a :c:type:`gearman_work_t` that has been built with a reducer, it takes the :c:type:`gearman_argument_t` and executs it against a :term:`function` as it normally would, but it tells the function to then process the results through a :term:`reducer` function that the :c:type:`gearman_work_t` was created with.
  22. 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 :term:`mapper` function will aggregate the work via an aggregator function, :c:type:`gearman_aggregator_fn`, and return a result.
  23. 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`.
  24. The result can be obtained from the task by calling
  25. :c:func:`gearman_task_result` to gain the :c:type:`gearman_result_st`.
  26. ------------
  27. RETURN VALUE
  28. ------------
  29. :c:func:`gearman_execute` returns a c:type:`gearman_task_st`.
  30. -------
  31. Example
  32. -------
  33. .. literalinclude:: examples/gearman_execute_example.c
  34. :language: c
  35. ----
  36. HOME
  37. ----
  38. To find out more information please check:
  39. `https://gearman.org/gearmand/ <https://gearman.org/gearmand/>`_
  40. --------
  41. SEE ALSO
  42. --------
  43. :manpage:`gearmand(8)` :manpage:`libgearman(3)`