universal.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/interface/client.hpp"
  40. // Get next connection that is ready for I/O.
  41. gearman_connection_st *gearman_ready(gearman_universal_st&);
  42. void gearman_universal_clone(gearman_universal_st &destination, const gearman_universal_st &source);
  43. void gearman_universal_free(gearman_universal_st &gearman);
  44. void gearman_free_all_packets(gearman_universal_st &gearman);
  45. gearman_return_t gearman_universal_set_option(gearman_universal_st &self, universal_options_t option, bool value);
  46. void gearman_set_log_fn(gearman_universal_st &self, gearman_log_fn *function, void *context, gearman_verbose_t verbose);
  47. void gearman_universal_set_timeout(gearman_universal_st &self, int timeout);
  48. int gearman_universal_timeout(gearman_universal_st &self);
  49. void gearman_universal_set_ssl(gearman_universal_st &self, bool ssl,
  50. const char *ca_file, const char *certificate, const char *key_file);
  51. void gearman_universal_set_namespace(gearman_universal_st &self, const char *namespace_key, size_t namespace_key_size);
  52. gearman_return_t cancel_job(gearman_universal_st& universal,
  53. gearman_job_handle_t job_handle);
  54. /**
  55. * Set custom memory allocation function for workloads. Normally gearman uses
  56. * the standard system malloc to allocate memory used with workloads. The
  57. * provided function will be used instead.
  58. */
  59. void gearman_set_workload_malloc_fn(gearman_universal_st&,
  60. gearman_malloc_fn *function,
  61. void *context);
  62. /**
  63. * Set custom memory free function for workloads. Normally gearman uses the
  64. * standard system free to free memory used with workloads. The provided
  65. * function will be used instead.
  66. */
  67. void gearman_set_workload_free_fn(gearman_universal_st&,
  68. gearman_free_fn *function,
  69. void *context);
  70. // Free all connections for a gearman structure.
  71. void gearman_free_all_cons(gearman_universal_st&);
  72. // Test echo with all connections.
  73. gearman_return_t gearman_echo(gearman_universal_st&, const void *workload, size_t workload_size);
  74. /**
  75. * Wait for I/O on connections.
  76. *
  77. */
  78. gearman_return_t gearman_wait(gearman_universal_st&);
  79. void gearman_nap(gearman_universal_st &self);
  80. void gearman_nap(int arg);
  81. static inline void gearman_universal_add_options(gearman_universal_st &self, universal_options_t options)
  82. {
  83. (void)gearman_universal_set_option(self, options, true);
  84. }
  85. static inline void gearman_universal_remove_options(gearman_universal_st &self, universal_options_t options)
  86. {
  87. (void)gearman_universal_set_option(self, options, false);
  88. }
  89. gearman_id_t gearman_universal_id(gearman_universal_st &universal);
  90. gearman_return_t gearman_set_identifier(gearman_universal_st& universal,
  91. const char *id,
  92. size_t id_size);
  93. const char *gearman_univeral_namespace(gearman_universal_st& universal);
  94. gearman_return_t gearman_server_option(gearman_universal_st&, gearman_string_t&);