client.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  2. *
  3. * Gearmand client and server library.
  4. *
  5. * Copyright (C) 2011 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 Client Declarations
  41. */
  42. #pragma once
  43. #include <libgearman-1.0/interface/client.h>
  44. /** @addtogroup gearman_client Client Declarations
  45. *
  46. * This is the interface gearman clients should use. You can run tasks one at a
  47. * time or concurrently.
  48. *
  49. * @ref main_page_client "See Main Page for full details."
  50. * @{
  51. */
  52. enum gearman_client_t {
  53. GEARMAN_CLIENT_STATE_IDLE,
  54. GEARMAN_CLIENT_STATE_NEW,
  55. GEARMAN_CLIENT_STATE_SUBMIT,
  56. GEARMAN_CLIENT_STATE_PACKET
  57. };
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /**
  62. * Initialize a client structure. Always check the return value even if passing
  63. * in a pre-allocated structure. Some other initialization may have failed. It
  64. * is not required to memset() a structure before providing it.
  65. *
  66. * @param[in] client Caller allocated structure, or NULL to allocate one.
  67. * @return On success, a pointer to the (possibly allocated) structure. On
  68. * failure this will be NULL.
  69. */
  70. GEARMAN_API
  71. gearman_client_st *gearman_client_create(gearman_client_st *client);
  72. /**
  73. * Clone a client structure.
  74. *
  75. * @param[in] client Caller allocated structure, or NULL to allocate one.
  76. * @param[in] from Structure to use as a source to clone from.
  77. * @return Same return as gearman_client_create().
  78. */
  79. GEARMAN_API
  80. gearman_client_st *gearman_client_clone(gearman_client_st *client,
  81. const gearman_client_st *from);
  82. /**
  83. * Free resources used by a client structure.
  84. *
  85. * @param[in] client Structure previously initialized with
  86. * gearman_client_create() or gearman_client_clone().
  87. */
  88. GEARMAN_API
  89. void gearman_client_free(gearman_client_st *client);
  90. /**
  91. * See gearman_error() for details.
  92. */
  93. GEARMAN_API
  94. const char *gearman_client_error(const gearman_client_st *client);
  95. GEARMAN_API
  96. gearman_return_t gearman_client_error_code(const gearman_client_st *client);
  97. /**
  98. * See gearman_errno() for details.
  99. */
  100. GEARMAN_API
  101. int gearman_client_errno(const gearman_client_st *client);
  102. /**
  103. * Get options for a client structure.
  104. *
  105. * @param[in] client Structure previously initialized with
  106. * gearman_client_create() or gearman_client_clone().
  107. * @return Options set for the client structure.
  108. */
  109. GEARMAN_API
  110. gearman_client_options_t gearman_client_options(const gearman_client_st *client);
  111. /**
  112. * Set options for a client structure.
  113. *
  114. * @param[in] client Structure previously initialized with
  115. * gearman_client_create() or gearman_client_clone().
  116. * @param[in] options Available options for client structures.
  117. */
  118. GEARMAN_API
  119. void gearman_client_set_options(gearman_client_st *client,
  120. gearman_client_options_t options);
  121. /**
  122. * Add options for a client structure.
  123. *
  124. * @param[in] client Structure previously initialized with
  125. * gearman_client_create() or gearman_client_clone().
  126. * @param[in] options Available options for client structures.
  127. */
  128. GEARMAN_API
  129. void gearman_client_add_options(gearman_client_st *client,
  130. gearman_client_options_t options);
  131. GEARMAN_API
  132. bool gearman_client_has_option(gearman_client_st *client,
  133. gearman_client_options_t option);
  134. /**
  135. * Remove options for a client structure.
  136. *
  137. * @param[in] client Structure previously initialized with
  138. * gearman_client_create() or gearman_client_clone().
  139. * @param[in] options Available options for client structures.
  140. */
  141. GEARMAN_API
  142. void gearman_client_remove_options(gearman_client_st *client,
  143. gearman_client_options_t options);
  144. /**
  145. * See gearman_universal_timeout() for details.
  146. */
  147. GEARMAN_API
  148. int gearman_client_timeout(gearman_client_st *client);
  149. /**
  150. * See gearman_universal_set_timeout() for details.
  151. */
  152. GEARMAN_API
  153. void gearman_client_set_timeout(gearman_client_st *client, int timeout);
  154. /**
  155. * See gearman_universal_set_ssl() for details.
  156. */
  157. GEARMAN_API
  158. void gearman_client_set_ssl(gearman_client_st *client, bool ssl,
  159. const char *ca_file, const char *certificate, const char *key_file);
  160. /**
  161. * Get the application context for a client.
  162. *
  163. * @param[in] client Structure previously initialized with
  164. * gearman_client_create() or gearman_client_clone().
  165. * @return Application context that was previously set, or NULL.
  166. */
  167. GEARMAN_API
  168. void *gearman_client_context(const gearman_client_st *client);
  169. /**
  170. * Set the application context for a client.
  171. *
  172. * @param[in] client Structure previously initialized with
  173. * gearman_client_create() or gearman_client_clone().
  174. * @param[in] context Application context to set.
  175. */
  176. GEARMAN_API
  177. void gearman_client_set_context(gearman_client_st *client, void *context);
  178. /**
  179. * See gearman_set_log_fn() for details.
  180. */
  181. GEARMAN_API
  182. void gearman_client_set_log_fn(gearman_client_st *client,
  183. gearman_log_fn *function, void *context,
  184. gearman_verbose_t verbose);
  185. /**
  186. * See gearman_set_workload_malloc_fn() for details.
  187. */
  188. GEARMAN_API
  189. void gearman_client_set_workload_malloc_fn(gearman_client_st *client,
  190. gearman_malloc_fn *function,
  191. void *context);
  192. /**
  193. * See gearman_set_workload_malloc_fn() for details.
  194. */
  195. GEARMAN_API
  196. void gearman_client_set_workload_free_fn(gearman_client_st *client,
  197. gearman_free_fn *function,
  198. void *context);
  199. GEARMAN_API
  200. gearman_return_t gearman_client_set_memory_allocators(gearman_client_st *,
  201. gearman_malloc_fn *malloc_fn,
  202. gearman_free_fn *free_fn,
  203. gearman_realloc_fn *realloc_fn,
  204. gearman_calloc_fn *calloc_fn,
  205. void *context);
  206. /**
  207. * Add a job server to a client. This goes into a list of servers that can be
  208. * used to run tasks. No socket I/O happens here, it is just added to a list.
  209. *
  210. * @param[in] client Structure previously initialized with
  211. * gearman_client_create() or gearman_client_clone().
  212. * @param[in] host Hostname or IP address (IPv4 or IPv6) of the server to add.
  213. * @param[in] port Port of the server to add.
  214. * @return Standard gearman return value.
  215. */
  216. GEARMAN_API
  217. gearman_return_t gearman_client_add_server(gearman_client_st *client,
  218. const char *host, in_port_t port);
  219. /**
  220. * Add a list of job servers to a client. The format for the server list is:
  221. * SERVER[:PORT][,SERVER[:PORT]]...
  222. * Some examples are:
  223. * 10.0.0.1,10.0.0.2,10.0.0.3
  224. * localhost234,jobserver2.domain.com:7003,10.0.0.3
  225. *
  226. * @param[in] client Structure previously initialized with
  227. * gearman_client_create() or gearman_client_clone().
  228. * @param[in] servers Server list described above.
  229. * @return Standard gearman return value.
  230. */
  231. GEARMAN_API
  232. gearman_return_t gearman_client_add_servers(gearman_client_st *client,
  233. const char *servers);
  234. /**
  235. * Remove all servers currently associated with the client.
  236. *
  237. * @param[in] client Structure previously initialized with
  238. * gearman_client_create() or gearman_client_clone().
  239. */
  240. GEARMAN_API
  241. void gearman_client_remove_servers(gearman_client_st *client);
  242. /**
  243. * When in non-blocking I/O mode, wait for activity from one of the servers.
  244. *
  245. * @param[in] client Structure previously initialized with
  246. * gearman_client_create() or gearman_client_clone().
  247. * @return Standard gearman return value.
  248. */
  249. GEARMAN_API
  250. gearman_return_t gearman_client_wait(gearman_client_st *client);
  251. /** @} */
  252. /**
  253. * @addtogroup gearman_client_single Single Task Interface
  254. * @ingroup gearman_client
  255. * Use the following set of functions to run one task at a time.
  256. *
  257. * @ref main_page_client_single "See Main Page for full details."
  258. * @{
  259. */
  260. /**
  261. * Run a single task and return an allocated result.
  262. *
  263. * @param[in] client Structure previously initialized with
  264. * gearman_client_create() or gearman_client_clone().
  265. * @param[in] function_name The name of the function to run.
  266. * @param[in] unique Optional unique job identifier, or NULL for a new UUID.
  267. * @param[in] workload The workload to pass to the function when it is run.
  268. * @param[in] workload_size Size of the workload.
  269. * @param[out] result_size The size of the data being returned.
  270. * @param[out] ret_ptr Standard gearman return value. In the case of
  271. * GEARMAN_WORK_DATA, GEARMAN_WORK_WARNING, or GEARMAN_WORK_STATUS, the caller
  272. * should take any actions to handle the event and then call this function
  273. * again. This may happen multiple times until a GEARMAN_WORK_ERROR,
  274. * GEARMAN_WORK_FAIL, or GEARMAN_SUCCESS (work complete) is returned. For
  275. * GEARMAN_WORK_DATA or GEARMAN_WORK_WARNING, the result_size will be set to
  276. * the intermediate data chunk being returned and an allocated data buffer
  277. * will be returned. For GEARMAN_WORK_STATUS, the caller can use
  278. * gearman_client_do_status() to get the current tasks status.
  279. * @return The result allocated by the library, this needs to be freed when the
  280. * caller is done using it.
  281. */
  282. GEARMAN_API
  283. void *gearman_client_do(gearman_client_st *client,
  284. const char *function_name,
  285. const char *unique,
  286. const void *workload, size_t workload_size,
  287. size_t *result_size,
  288. gearman_return_t *ret_ptr);
  289. /**
  290. * Run a high priority task and return an allocated result. See
  291. * gearman_client_do() for parameter and return information.
  292. */
  293. GEARMAN_API
  294. void *gearman_client_do_high(gearman_client_st *client,
  295. const char *function_name, const char *unique,
  296. const void *workload, size_t workload_size,
  297. size_t *result_size, gearman_return_t *ret_ptr);
  298. /**
  299. * Run a low priority task and return an allocated result. See
  300. * gearman_client_do() for parameter and return information.
  301. */
  302. GEARMAN_API
  303. void *gearman_client_do_low(gearman_client_st *client,
  304. const char *function_name, const char *unique,
  305. const void *workload, size_t workload_size,
  306. size_t *result_size, gearman_return_t *ret_ptr);
  307. /**
  308. * Get the job handle for the running task. This should be used between
  309. * repeated gearman_client_do() (and related) calls to get information.
  310. *
  311. * @param[in] client Structure previously initialized with
  312. * gearman_client_create() or gearman_client_clone().
  313. * @return Pointer to static buffer in the client structure that holds the job
  314. * handle.
  315. */
  316. GEARMAN_API
  317. const char *gearman_client_do_job_handle(gearman_client_st *client);
  318. // Deprecatd
  319. GEARMAN_API
  320. void gearman_client_do_status(gearman_client_st *client, uint32_t *numerator,
  321. uint32_t *denominator);
  322. /**
  323. * Run a task in the background.
  324. *
  325. * @param[in] client Structure previously initialized with
  326. * gearman_client_create() or gearman_client_clone().
  327. * @param[in] function_name The name of the function to run.
  328. * @param[in] unique Optional unique job identifier, or NULL for a new UUID.
  329. * @param[in] workload The workload to pass to the function when it is run.
  330. * @param[in] workload_size Size of the workload.
  331. * @param[out] job_handle A buffer to store the job handle in. Must be at least
  332. GEARMAN_JOB_HANDLE_SIZE bytes long.
  333. * @return Standard gearman return value.
  334. */
  335. GEARMAN_API
  336. gearman_return_t gearman_client_do_background(gearman_client_st *client,
  337. const char *function_name,
  338. const char *unique,
  339. const void *workload,
  340. size_t workload_size,
  341. gearman_job_handle_t job_handle);
  342. /**
  343. * Run a high priority task in the background. See
  344. * gearman_client_do_background() for parameter and return information.
  345. */
  346. GEARMAN_API
  347. gearman_return_t gearman_client_do_high_background(gearman_client_st *client,
  348. const char *function_name,
  349. const char *unique,
  350. const void *workload,
  351. size_t workload_size,
  352. gearman_job_handle_t job_handle);
  353. /**
  354. * Run a low priority task in the background. See
  355. * gearman_client_do_background() for parameter and return information.
  356. */
  357. GEARMAN_API
  358. gearman_return_t gearman_client_do_low_background(gearman_client_st *client,
  359. const char *function_name,
  360. const char *unique,
  361. const void *workload,
  362. size_t workload_size,
  363. gearman_job_handle_t job_handle);
  364. /**
  365. * Get the status for a backgound job.
  366. *
  367. * @param[in] client Structure previously initialized with
  368. * gearman_client_create() or gearman_client_clone().
  369. * @param[in] job_handle The job handle to get status for.
  370. * @param[out] is_known Optional parameter to store the known status in.
  371. * @param[out] is_running Optional parameter to store the running status in.
  372. * @param[out] numerator Optional parameter to store the numerator in.
  373. * @param[out] denominator Optional parameter to store the denominator in.
  374. * @return Standard gearman return value.
  375. */
  376. GEARMAN_API
  377. gearman_return_t gearman_client_job_status(gearman_client_st *client,
  378. const gearman_job_handle_t job_handle,
  379. bool *is_known, bool *is_running,
  380. uint32_t *numerator,
  381. uint32_t *denominator);
  382. GEARMAN_API
  383. gearman_status_t gearman_client_unique_status(gearman_client_st *client,
  384. const char *unique, size_t unique_length);
  385. // This is not in the API yet, subject to change
  386. GEARMAN_API
  387. gearman_task_st *gearman_client_add_task_status_by_unique(gearman_client_st *client,
  388. gearman_task_st *task_ptr,
  389. const char *unique_handle,
  390. gearman_return_t *ret_ptr);
  391. /**
  392. * Send data to all job servers to see if they echo it back. This is a test
  393. * function to see if the job servers are responding properly.
  394. *
  395. * @param[in] client Structure previously initialized with
  396. * gearman_client_create() or gearman_client_clone().
  397. * @param[in] workload The workload to ask the server to echo back.
  398. * @param[in] workload_size Size of the workload.
  399. * @return Standard gearman return value.
  400. */
  401. GEARMAN_API
  402. gearman_return_t gearman_client_echo(gearman_client_st *client,
  403. const void *workload,
  404. size_t workload_size);
  405. /** @} */
  406. /**
  407. * @addtogroup gearman_client_concurrent Concurrent Task Interface
  408. * @ingroup gearman_client
  409. * Use the following set of functions to multiple run tasks concurrently.
  410. *
  411. * @ref main_page_client_concurrent "See Main Page for full details."
  412. * @{
  413. */
  414. /**
  415. * Free all tasks for a gearman structure.
  416. *
  417. * @param[in] client Structure previously initialized with
  418. * gearman_client_create() or gearman_client_clone().
  419. */
  420. GEARMAN_API
  421. void gearman_client_task_free_all(gearman_client_st *client);
  422. /**
  423. * Set function to call when tasks are being cleaned up so applications can
  424. * clean up the task context.
  425. *
  426. * @param[in] client Structure previously initialized with
  427. * gearman_client_create() or gearman_client_clone().
  428. * @param[in] function Function to call to clean up task context.
  429. */
  430. GEARMAN_API
  431. void gearman_client_set_task_context_free_fn(gearman_client_st *client,
  432. gearman_task_context_free_fn *function);
  433. /**
  434. * Add a task to be run in parallel.
  435. *
  436. * @param[in] client Structure previously initialized with
  437. * gearman_client_create() or gearman_client_clone().
  438. * @param[in] task Caller allocated structure, or NULL to allocate one.
  439. * @param[in] context Application context to associate with the task.
  440. * @param[in] function_name The name of the function to run.
  441. * @param[in] unique Optional unique job identifier, or NULL for a new UUID.
  442. * @param[in] workload The workload to pass to the function when it is run.
  443. * @param[in] workload_size Size of the workload.
  444. * @param[out] ret_ptr Standard gearman return value.
  445. * @return On success, a pointer to the (possibly allocated) structure. On
  446. * failure this will be NULL.
  447. */
  448. GEARMAN_API
  449. gearman_task_st *gearman_client_add_task(gearman_client_st *client,
  450. gearman_task_st *task,
  451. void *context,
  452. const char *function_name,
  453. const char *unique,
  454. const void *workload,
  455. size_t workload_size,
  456. gearman_return_t *ret_ptr);
  457. /**
  458. * Add a high priority task to be run in parallel. See
  459. * gearman_client_add_task() for details.
  460. */
  461. GEARMAN_API
  462. gearman_task_st *gearman_client_add_task_high(gearman_client_st *client,
  463. gearman_task_st *task,
  464. void *context,
  465. const char *function_name,
  466. const char *unique,
  467. const void *workload,
  468. size_t workload_size,
  469. gearman_return_t *ret_ptr);
  470. /**
  471. * Add a low priority task to be run in parallel. See
  472. * gearman_client_add_task() for details.
  473. */
  474. GEARMAN_API
  475. gearman_task_st *gearman_client_add_task_low(gearman_client_st *client,
  476. gearman_task_st *task,
  477. void *context,
  478. const char *function_name,
  479. const char *unique,
  480. const void *workload,
  481. size_t workload_size,
  482. gearman_return_t *ret_ptr);
  483. /**
  484. * Add a background task to be run in parallel. See
  485. * gearman_client_add_task() for details.
  486. */
  487. GEARMAN_API
  488. gearman_task_st *gearman_client_add_task_background(gearman_client_st *client,
  489. gearman_task_st *task,
  490. void *context,
  491. const char *function_name,
  492. const char *unique,
  493. const void *workload,
  494. size_t workload_size,
  495. gearman_return_t *ret_ptr);
  496. /**
  497. * Add a high priority background task to be run in parallel. See
  498. * gearman_client_add_task() for details.
  499. */
  500. GEARMAN_API
  501. gearman_task_st *gearman_client_add_task_high_background(gearman_client_st *client,
  502. gearman_task_st *task,
  503. void *context,
  504. const char *function_name,
  505. const char *unique,
  506. const void *workload,
  507. size_t workload_size,
  508. gearman_return_t *ret_ptr);
  509. /**
  510. * Add a low priority background task to be run in parallel. See
  511. * gearman_client_add_task() for details.
  512. */
  513. GEARMAN_API
  514. gearman_task_st *gearman_client_add_task_low_background(gearman_client_st *client,
  515. gearman_task_st *task,
  516. void *context,
  517. const char *function_name,
  518. const char *unique,
  519. const void *workload,
  520. size_t workload_size,
  521. gearman_return_t *ret_ptr);
  522. /**
  523. * Add task to get the status for a backgound task in parallel.
  524. *
  525. * @param[in] client Structure previously initialized with
  526. * gearman_client_create() or gearman_client_clone().
  527. * @param[in] task Caller allocated structure, or NULL to allocate one.
  528. * @param[in] context Application context to associate with the task.
  529. * @param[in] job_handle The job handle to get status for.
  530. * @param[out] ret_ptr Standard gearman return value.
  531. * @return On success, a pointer to the (possibly allocated) structure. On
  532. * failure this will be NULL.
  533. */
  534. GEARMAN_API
  535. gearman_task_st *gearman_client_add_task_status(gearman_client_st *client,
  536. gearman_task_st *task,
  537. void *context,
  538. const char *job_handle,
  539. gearman_return_t *ret_ptr);
  540. /**
  541. * Callback function when workload data needs to be sent for a task.
  542. *
  543. * @param[in] client Structure previously initialized with
  544. * gearman_client_create() or gearman_client_clone().
  545. * @param[in] function Function to call.
  546. */
  547. GEARMAN_API
  548. void gearman_client_set_workload_fn(gearman_client_st *client,
  549. gearman_workload_fn *function);
  550. /**
  551. * Callback function when a job has been created for a task.
  552. *
  553. * @param[in] client Structure previously initialized with
  554. * gearman_client_create() or gearman_client_clone().
  555. * @param[in] function Function to call.
  556. */
  557. GEARMAN_API
  558. void gearman_client_set_created_fn(gearman_client_st *client,
  559. gearman_created_fn *function);
  560. /**
  561. * Callback function when there is a data packet for a task.
  562. *
  563. * @param[in] client Structure previously initialized with
  564. * gearman_client_create() or gearman_client_clone().
  565. * @param[in] function Function to call.
  566. */
  567. GEARMAN_API
  568. void gearman_client_set_data_fn(gearman_client_st *client,
  569. gearman_data_fn *function);
  570. /**
  571. * Callback function when there is a warning packet for a task.
  572. *
  573. * @param[in] client Structure previously initialized with
  574. * gearman_client_create() or gearman_client_clone().
  575. * @param[in] function Function to call.
  576. */
  577. GEARMAN_API
  578. void gearman_client_set_warning_fn(gearman_client_st *client,
  579. gearman_warning_fn *function);
  580. /**
  581. * Callback function when there is a status packet for a task.
  582. *
  583. * @param[in] client Structure previously initialized with
  584. * gearman_client_create() or gearman_client_clone().
  585. * @param[in] function Function to call.
  586. */
  587. GEARMAN_API
  588. void gearman_client_set_status_fn(gearman_client_st *client,
  589. gearman_universal_status_fn *function);
  590. /**
  591. * Callback function when a task is complete.
  592. *
  593. * @param[in] client Structure previously initialized with
  594. * gearman_client_create() or gearman_client_clone().
  595. * @param[in] function Function to call.
  596. */
  597. GEARMAN_API
  598. void gearman_client_set_complete_fn(gearman_client_st *client,
  599. gearman_complete_fn *function);
  600. /**
  601. * Callback function when there is an exception packet for a task.
  602. *
  603. * @param[in] client Structure previously initialized with
  604. * gearman_client_create() or gearman_client_clone().
  605. * @param[in] function Function to call.
  606. */
  607. GEARMAN_API
  608. void gearman_client_set_exception_fn(gearman_client_st *client,
  609. gearman_exception_fn *function);
  610. /**
  611. * Callback function when a task has failed.
  612. *
  613. * @param[in] client Structure previously initialized with
  614. * gearman_client_create() or gearman_client_clone().
  615. * @param[in] function Function to call.
  616. */
  617. GEARMAN_API
  618. void gearman_client_set_fail_fn(gearman_client_st *client,
  619. gearman_fail_fn *function);
  620. /**
  621. * Clear all task callback functions.
  622. *
  623. * @param[in] client Structure previously initialized with
  624. * gearman_client_create() or gearman_client_clone().
  625. */
  626. GEARMAN_API
  627. void gearman_client_clear_fn(gearman_client_st *client);
  628. /**
  629. * Run tasks that have been added in parallel.
  630. *
  631. * @param[in] client Structure previously initialized with
  632. * gearman_client_create() or gearman_client_clone().
  633. * @return Standard gearman return value.
  634. */
  635. GEARMAN_API
  636. gearman_return_t gearman_client_run_tasks(gearman_client_st *client);
  637. GEARMAN_API
  638. bool gearman_client_compare(const gearman_client_st *first, const gearman_client_st *second);
  639. GEARMAN_API
  640. bool gearman_client_set_server_option(gearman_client_st *self, const char *option_arg, size_t option_arg_size);
  641. GEARMAN_API
  642. void gearman_client_set_namespace(gearman_client_st *self, const char *namespace_key, size_t namespace_key_size);
  643. GEARMAN_API
  644. gearman_return_t gearman_client_set_identifier(gearman_client_st *client,
  645. const char *id, size_t id_size);
  646. const char *gearman_client_namespace(gearman_client_st *self);
  647. GEARMAN_API
  648. bool gearman_client_has_tasks(const gearman_client_st *client);
  649. GEARMAN_API
  650. bool gearman_client_has_active_tasks(gearman_client_st *client);
  651. /** @} */
  652. #ifdef __cplusplus
  653. }
  654. #endif