queue.cc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  2. *
  3. * Gearmand client and server library.
  4. *
  5. * Copyright (C) 2012 Data Differential, http://datadifferential.com/
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are
  10. * met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * * Redistributions in binary form must reproduce the above
  16. * copyright notice, this list of conditions and the following disclaimer
  17. * in the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * * The names of its contributors may not be used to endorse or
  21. * promote products derived from this software without specific prior
  22. * written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. */
  37. /**
  38. * @file
  39. * @brief default Queue Storage Definitions
  40. */
  41. #include <gear_config.h>
  42. #include <libgearman-server/common.h>
  43. #include <libgearman-server/plugins/queue/default/queue.h>
  44. #include <libgearman-server/plugins/queue/base.h>
  45. /**
  46. * @addtogroup gearman_queue_default_static Static default Queue Storage Definitions
  47. * @ingroup gearman_queue_default
  48. * @{
  49. */
  50. namespace gearmand { namespace plugins { namespace queue { class Default; }}}
  51. #pragma GCC diagnostic push
  52. #pragma GCC diagnostic ignored "-Wold-style-cast"
  53. /* Queue callback functions. */
  54. static gearmand_error_t __add(gearman_server_st *server __attribute__((unused)),
  55. void *context __attribute__((unused)),
  56. const char *unique __attribute__((unused)), size_t unique_size __attribute__((unused)),
  57. const char *function_name __attribute__((unused)),
  58. size_t function_name_size __attribute__((unused)),
  59. const void *data __attribute__((unused)), size_t data_size __attribute__((unused)),
  60. gearman_job_priority_t priority __attribute__((unused)),
  61. int64_t when __attribute__((unused)))
  62. {
  63. gearmand_debug(__func__);
  64. return GEARMAND_SUCCESS;
  65. }
  66. static gearmand_error_t __flush(gearman_server_st *server __attribute__((unused)),
  67. void *context __attribute__((unused)))
  68. {
  69. gearmand_debug(__func__);
  70. return GEARMAND_SUCCESS;
  71. }
  72. static gearmand_error_t __done(gearman_server_st *server __attribute__((unused)),
  73. void *context __attribute__((unused)),
  74. const char *unique __attribute__((unused)),
  75. size_t unique_size __attribute__((unused)),
  76. const char *function_name __attribute__((unused)),
  77. size_t function_name_size __attribute__((unused)))
  78. {
  79. gearmand_debug(__func__);
  80. return GEARMAND_SUCCESS;
  81. }
  82. static gearmand_error_t __replay(gearman_server_st *server __attribute__((unused)),
  83. void *context __attribute__((unused)),
  84. gearman_queue_add_fn *add_fn __attribute__((unused)),
  85. void *add_context __attribute__((unused)))
  86. {
  87. gearmand_debug(__func__);
  88. return GEARMAND_SUCCESS;
  89. }
  90. namespace gearmand {
  91. namespace plugins {
  92. namespace queue {
  93. class Default :
  94. public gearmand::plugins::Queue
  95. {
  96. public:
  97. Default();
  98. ~Default();
  99. gearmand_error_t initialize();
  100. private:
  101. };
  102. Default::Default() :
  103. Queue("builtin")
  104. {
  105. }
  106. Default::~Default()
  107. {
  108. }
  109. gearmand_error_t Default::initialize()
  110. {
  111. gearman_server_set_queue(Gearmand()->server, this, __add, __flush, __done, __replay);
  112. return GEARMAND_SUCCESS;
  113. }
  114. void initialize_default()
  115. {
  116. static Default local_instance;
  117. }
  118. } // namespace queue
  119. } // namespace plugins
  120. } // namespace gearmand
  121. #pragma GCC diagnostic pop