constants.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  2. *
  3. * Gearmand client and server library.
  4. *
  5. * Copyright (C) 2011-2012 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 Defines, typedefs, and enums
  41. */
  42. #pragma once
  43. #ifdef __cplusplus
  44. #include <cstdlib>
  45. #else
  46. #include <stdlib.h>
  47. #endif
  48. #include <libgearman-1.0/limits.h>
  49. #include <libgearman-1.0/priority.h>
  50. #include <libgearman-server/verbose.h>
  51. /**
  52. * @addtogroup gearman_server_constants Constants
  53. * @ingroup gearman_server
  54. * @{
  55. */
  56. /* Defines. */
  57. #define GEARMAND_ARGS_BUFFER_SIZE 128
  58. #define GEARMAND_CONF_DISPLAY_WIDTH 80
  59. #define GEARMAND_CONF_MAX_OPTION_SHORT 128
  60. #define GEARMAND_DEFAULT_BACKLOG 64
  61. #define GEARMAND_DEFAULT_MAX_QUEUE_SIZE 0
  62. #define GEARMAND_DEFAULT_SOCKET_RECV_SIZE 32768
  63. #define GEARMAND_DEFAULT_SOCKET_SEND_SIZE 32768
  64. #define GEARMAND_DEFAULT_SOCKET_TIMEOUT 10
  65. #define GEARMAND_JOB_HANDLE_SIZE 64
  66. #define GEARMAND_DEFAULT_HASH_SIZE 991
  67. #define GEARMAND_MAX_COMMAND_ARGS 8
  68. #define GEARMAND_MAX_FREE_SERVER_CLIENT 1000
  69. #define GEARMAND_MAX_FREE_SERVER_CON 1000
  70. #define GEARMAND_MAX_FREE_SERVER_JOB 1000
  71. #define GEARMAND_MAX_FREE_SERVER_PACKET 2000
  72. #define GEARMAND_MAX_FREE_SERVER_WORKER 1000
  73. #define GEARMAND_OPTION_SIZE 64
  74. #define GEARMAND_PACKET_HEADER_SIZE 12
  75. #define GEARMAND_PIPE_BUFFER_SIZE 256
  76. #define GEARMAND_RECV_BUFFER_SIZE 8192
  77. #define GEARMAND_SEND_BUFFER_SIZE 8192
  78. #define GEARMAND_SERVER_CON_ID_SIZE 128
  79. #define GEARMAND_TEXT_RESPONSE_SIZE 8192
  80. #define GEARMAN_MAGIC_MEMORY (void*)(0x000001)
  81. /** @} */
  82. /** @} */
  83. enum gearmand_connection_options_t
  84. {
  85. GEARMAND_CON_PACKET_IN_USE,
  86. GEARMAND_CON_EXTERNAL_FD,
  87. GEARMAND_CON_CLOSE_AFTER_FLUSH,
  88. GEARMAND_CON_MAX
  89. };
  90. struct gearman_server_thread_st;
  91. struct gearman_server_st;
  92. struct gearman_server_con_st;
  93. struct gearmand_io_st;
  94. #ifdef __cplusplus
  95. extern "C" {
  96. #endif
  97. /* Function types. */
  98. typedef void (gearman_server_thread_run_fn)(gearman_server_thread_st *thread,
  99. void *context);
  100. typedef gearmand_error_t (gearman_queue_add_fn)(gearman_server_st *server,
  101. void *context,
  102. const char *unique,
  103. size_t unique_size,
  104. const char *function_name,
  105. size_t function_name_size,
  106. const void *data,
  107. size_t data_size,
  108. gearman_job_priority_t priority,
  109. int64_t when);
  110. typedef gearmand_error_t (gearman_queue_flush_fn)(gearman_server_st *server,
  111. void *context);
  112. typedef gearmand_error_t (gearman_queue_done_fn)(gearman_server_st *server,
  113. void *context,
  114. const char *unique,
  115. size_t unique_size,
  116. const char *function_name,
  117. size_t function_name_size);
  118. typedef gearmand_error_t (gearman_queue_replay_fn)(gearman_server_st *server,
  119. void *context,
  120. gearman_queue_add_fn *add_fn,
  121. void *add_context);
  122. typedef gearmand_error_t (gearmand_connection_add_fn)(gearman_server_con_st *con);
  123. typedef gearmand_error_t (gearmand_connection_remove_fn)(gearman_server_con_st *con);
  124. typedef void (gearman_log_server_fn)(const char *line, gearmand_verbose_t verbose,
  125. struct gearmand_thread_st *context);
  126. typedef gearmand_error_t (gearmand_event_watch_fn)(gearmand_io_st *con,
  127. short events, void *context);
  128. typedef void (gearmand_connection_protocol_context_free_fn)(gearman_server_con_st *con,
  129. void *context);
  130. typedef void (gearmand_log_fn)(const char *line, gearmand_verbose_t verbose,
  131. void *context);
  132. /** @} */
  133. /**
  134. * @addtogroup gearman_server_protocol Protocol Plugins
  135. * @ingroup gearman_server
  136. */
  137. /**
  138. * @addtogroup gearman_server_queue Queue Plugins
  139. * @ingroup gearman_server
  140. */
  141. #ifdef __cplusplus
  142. }
  143. #endif