job.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  2. *
  3. * Gearmand client and server library.
  4. *
  5. * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  6. * Copyright (C) 2008 Brian Aker, Eric Day
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are
  11. * met:
  12. *
  13. * * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * * Redistributions in binary form must reproduce the above
  17. * copyright notice, this list of conditions and the following disclaimer
  18. * in the documentation and/or other materials provided with the
  19. * distribution.
  20. *
  21. * * The names of its contributors may not be used to endorse or
  22. * promote products derived from this software without specific prior
  23. * written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. */
  38. /**
  39. * @file
  40. * @brief Job Declarations
  41. */
  42. #pragma once
  43. #include <libgearman-1.0/interface/job.h>
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /**
  48. * @addtogroup gearman_job Job Declarations
  49. * @ingroup gearman_worker
  50. *
  51. * The job functions are used to manage jobs assigned to workers. It is most
  52. * commonly used with the worker interface.
  53. *
  54. * @{
  55. */
  56. /** Free a job structure.
  57. *
  58. * @param[in] job Structure previously initialized with
  59. * gearman_worker_grab_job().
  60. */
  61. GEARMAN_API
  62. void gearman_job_free(gearman_job_st *job);
  63. /**
  64. * Send data for a running job.
  65. */
  66. GEARMAN_API
  67. gearman_return_t gearman_job_send_data(gearman_job_st *job,
  68. const void *data, size_t data_size);
  69. /**
  70. * Send warning for a running job.
  71. */
  72. GEARMAN_API
  73. gearman_return_t gearman_job_send_warning(gearman_job_st *job,
  74. const void *warning,
  75. size_t warning_size);
  76. /**
  77. * Send status information for a running job.
  78. */
  79. GEARMAN_API
  80. gearman_return_t gearman_job_send_status(gearman_job_st *job,
  81. uint32_t numerator,
  82. uint32_t denominator);
  83. /**
  84. * Send result and complete status for a job.
  85. */
  86. GEARMAN_API
  87. gearman_return_t gearman_job_send_complete(gearman_job_st *job,
  88. const void *result,
  89. size_t result_size);
  90. /** Send exception for a running job.
  91. */
  92. GEARMAN_API
  93. gearman_return_t gearman_job_send_exception(gearman_job_st *job,
  94. const void *exception,
  95. size_t exception_size);
  96. /**
  97. * Send fail status for a job.
  98. */
  99. GEARMAN_API
  100. gearman_return_t gearman_job_send_fail(gearman_job_st *job);
  101. /** Get job handle.
  102. */
  103. GEARMAN_API
  104. const char *gearman_job_handle(const gearman_job_st *job);
  105. /**
  106. * Get the function name associated with a job.
  107. */
  108. GEARMAN_API
  109. const char *gearman_job_function_name(const gearman_job_st *job);
  110. /** Get the unique ID associated with a job.
  111. */
  112. GEARMAN_API
  113. const char *gearman_job_unique(const gearman_job_st *job);
  114. /** Get a pointer to the workload for a job.
  115. */
  116. GEARMAN_API
  117. const void *gearman_job_workload(const gearman_job_st *job);
  118. /**
  119. * Get size of the workload for a job.
  120. */
  121. GEARMAN_API
  122. size_t gearman_job_workload_size(const gearman_job_st *job);
  123. /**
  124. * Take allocated workload from job. After this, the caller is responsible
  125. * for free()ing the memory.
  126. */
  127. GEARMAN_API
  128. void *gearman_job_take_workload(gearman_job_st *job, size_t *data_size);
  129. GEARMAN_API
  130. gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job);
  131. GEARMAN_API
  132. gearman_client_st *gearman_job_use_client(gearman_job_st *job);
  133. GEARMAN_API
  134. const char *gearman_job_error(gearman_job_st *job);
  135. /** @} */
  136. #ifdef __cplusplus
  137. }
  138. #endif