constants.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. #pragma once
  39. #include <libgearman-1.0/priority.h>
  40. #include <libgearman-1.0/protocol.h>
  41. #include <libgearman-1.0/return.h>
  42. #include <libgearman-1.0/limits.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @addtogroup gearman_constants Constants
  48. * @ingroup gearman_universal
  49. * @ingroup gearman_client
  50. * @ingroup gearman_worker
  51. * @{
  52. */
  53. /**
  54. * Verbosity levels.
  55. */
  56. typedef enum
  57. {
  58. GEARMAN_VERBOSE_NEVER,
  59. GEARMAN_VERBOSE_FATAL,
  60. GEARMAN_VERBOSE_ERROR,
  61. GEARMAN_VERBOSE_INFO,
  62. GEARMAN_VERBOSE_DEBUG,
  63. GEARMAN_VERBOSE_CRAZY,
  64. GEARMAN_VERBOSE_MAX
  65. } gearman_verbose_t;
  66. /** @} */
  67. /**
  68. * @ingroup gearman_universal
  69. * Options for gearman_universal_st.
  70. */
  71. typedef enum
  72. {
  73. GEARMAN_NON_BLOCKING,
  74. GEARMAN_DONT_TRACK_PACKETS,
  75. GEARMAN_MAX
  76. } gearman_universal_options_t;
  77. /**
  78. * @ingroup gearman_con
  79. * Options for gearman_connection_st.
  80. */
  81. typedef enum
  82. {
  83. GEARMAN_CON_READY,
  84. GEARMAN_CON_PACKET_IN_USE,
  85. GEARMAN_CON_EXTERNAL_FD,
  86. GEARMAN_CON_IGNORE_LOST_CONNECTION,
  87. GEARMAN_CON_CLOSE_AFTER_FLUSH,
  88. GEARMAN_CON_MAX
  89. } gearman_connection_options_t;
  90. /**
  91. * @ingroup gearman_client
  92. * Options for gearman_client_st.
  93. */
  94. typedef enum
  95. {
  96. GEARMAN_CLIENT_ALLOCATED= (1 << 0),
  97. GEARMAN_CLIENT_NON_BLOCKING= (1 << 1),
  98. GEARMAN_CLIENT_TASK_IN_USE= (1 << 2),
  99. GEARMAN_CLIENT_UNBUFFERED_RESULT= (1 << 3),
  100. GEARMAN_CLIENT_NO_NEW= (1 << 4),
  101. GEARMAN_CLIENT_FREE_TASKS= (1 << 5),
  102. GEARMAN_CLIENT_GENERATE_UNIQUE= (1 << 6),
  103. GEARMAN_CLIENT_EXCEPTION= (1 << 7),
  104. GEARMAN_CLIENT_SSL= (1 << 8),
  105. GEARMAN_CLIENT_MAX= (1 << 9)
  106. } gearman_client_options_t;
  107. /**
  108. * @ingroup gearman_worker
  109. * Options for gearman_worker_st.
  110. */
  111. typedef enum
  112. {
  113. GEARMAN_WORKER_ALLOCATED= (1 << 0),
  114. GEARMAN_WORKER_NON_BLOCKING= (1 << 1),
  115. GEARMAN_WORKER_PACKET_INIT= (1 << 2),
  116. GEARMAN_WORKER_GRAB_JOB_IN_USE= (1 << 3),
  117. GEARMAN_WORKER_PRE_SLEEP_IN_USE= (1 << 4),
  118. GEARMAN_WORKER_WORK_JOB_IN_USE= (1 << 5),
  119. GEARMAN_WORKER_CHANGE= (1 << 6),
  120. GEARMAN_WORKER_GRAB_UNIQ= (1 << 7),
  121. GEARMAN_WORKER_TIMEOUT_RETURN= (1 << 8),
  122. GEARMAN_WORKER_GRAB_ALL= (1 << 9),
  123. GEARMAN_WORKER_SSL= (1 << 10),
  124. GEARMAN_WORKER_IDENTIFIER= (1 << 11),
  125. GEARMAN_WORKER_MAX= (1 << 12)
  126. } gearman_worker_options_t;
  127. /* Types. */
  128. typedef struct gearman_task_st gearman_task_st;
  129. typedef struct gearman_client_st gearman_client_st;
  130. typedef struct gearman_job_st gearman_job_st;
  131. typedef struct gearman_worker_st gearman_worker_st;
  132. typedef struct gearman_allocator_t gearman_allocator_t;
  133. typedef struct gearman_task_attr_t gearman_task_attr_t;
  134. typedef struct gearman_result_st gearman_result_st;
  135. typedef struct gearman_string_t gearman_string_t;
  136. typedef struct gearman_argument_t gearman_argument_t;
  137. typedef struct gearman_status_t gearman_status_t;
  138. // Custom allocators
  139. typedef void* (gearman_malloc_fn)(size_t size, void *context);
  140. typedef void* (gearman_realloc_fn)(void *ptr, size_t size, void *context);
  141. typedef void* (gearman_calloc_fn)(size_t nelm, size_t size, void *context);
  142. typedef void (gearman_free_fn)(void *ptr, void *context);
  143. typedef gearman_return_t (gearman_parse_server_fn)(const char *host, in_port_t port, void *context);
  144. typedef void (gearman_task_context_free_fn)(gearman_task_st *task, void *context);
  145. typedef void (gearman_log_fn)(const char *line, gearman_verbose_t verbose, void *context);
  146. // Worker types
  147. typedef void* (gearman_worker_fn)(gearman_job_st *job, void *context,
  148. size_t *result_size,
  149. gearman_return_t *ret_ptr);
  150. typedef gearman_return_t (gearman_function_fn)(gearman_job_st *job, void *worker_context);
  151. typedef struct gearman_aggregator_st gearman_aggregator_st;
  152. typedef gearman_return_t (gearman_aggregator_fn)(gearman_aggregator_st *, gearman_task_st *, gearman_result_st *);
  153. /** @} */
  154. #ifdef __cplusplus
  155. }
  156. #endif