server.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Gearman server and library
  2. * Copyright (C) 2008 Brian Aker, Eric Day
  3. * All rights reserved.
  4. *
  5. * Use and distribution licensed under the BSD license. See
  6. * the COPYING file in the parent directory for full text.
  7. */
  8. /**
  9. * @file
  10. * @brief Gearman Server Declarations
  11. */
  12. #include <libgearman-server/struct/server.h>
  13. #pragma once
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include <pthread.h>
  18. inline static void gearmand_set_round_robin(gearman_server_st *server, bool round_robin)
  19. {
  20. server->flags.round_robin= round_robin;
  21. }
  22. /**
  23. * Process commands for a connection.
  24. * @param server_con Server connection that has a packet to process.
  25. * @param packet The packet that needs processing.
  26. * @return Standard gearman return value.
  27. */
  28. GEARMAN_API
  29. gearmand_error_t gearman_server_run_command(gearman_server_con_st *server_con,
  30. gearmand_packet_st *packet);
  31. /**
  32. * Tell server that it should enter a graceful shutdown state.
  33. * @param server Server structure previously initialized with
  34. * gearman_server_create.
  35. * @return Standard gearman return value. This will return GEARMAN_SHUTDOWN if
  36. * the server is ready to shutdown now.
  37. */
  38. GEARMAN_API
  39. gearmand_error_t gearman_server_shutdown_graceful(gearman_server_st *server);
  40. /**
  41. * Replay the persistent queue to load all unfinshed jobs into the server. This
  42. * should only be run at startup.
  43. * @param server Server structure previously initialized with
  44. * gearman_server_create.
  45. * @return Standard gearman return value. This will return GEARMAN_SHUTDOWN if
  46. * the server is ready to shutdown now.
  47. */
  48. GEARMAN_API
  49. gearmand_error_t gearman_server_queue_replay(gearman_server_st *server);
  50. /**
  51. * Get persistent queue context.
  52. */
  53. GEARMAN_API
  54. void *gearman_server_queue_context(const gearman_server_st *server);
  55. /**
  56. * Set persistent queue context that will be passed back to all queue callback
  57. * functions.
  58. */
  59. GEARMAN_API
  60. void gearman_server_set_queue(gearman_server_st *server,
  61. void *context,
  62. gearman_queue_add_fn *add,
  63. gearman_queue_flush_fn *flush,
  64. gearman_queue_done_fn *done,
  65. gearman_queue_replay_fn *replay);
  66. /** @} */
  67. #ifdef __cplusplus
  68. }
  69. #endif