messenger.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef HADOOP_CORE_RPC_MSGR_H
  19. #define HADOOP_CORE_RPC_MSGR_H
  20. struct hrpc_call;
  21. struct hrpc_messenger;
  22. struct hrpc_messenger_builder;
  23. #include <stdint.h> // for int32_t
  24. /**
  25. * Allocate a Hadoop messenger builder.
  26. *
  27. * @return A Hadoop messenger builder, or NULL on OOM.
  28. */
  29. struct hrpc_messenger_builder *hrpc_messenger_builder_alloc(void);
  30. /**
  31. * Set the timeout for the Hadoop messenger.
  32. *
  33. * @param bld The messenger builder.
  34. * @param timeout_ms The timeout in milliseconds
  35. */
  36. void hrpc_messenger_builder_set_timeout_ms(struct hrpc_messenger_builder *bld,
  37. int32_t timeout_ms);
  38. /**
  39. * Free a Hadoop messenger builder.
  40. *
  41. * @param bld The Hadoop proxy builder to free.
  42. */
  43. void hrpc_messenger_builder_free(struct hrpc_messenger_builder *bld);
  44. /**
  45. * Create a Hadoop messenger.
  46. *
  47. * @param bld The Hadoop messenger builder to use.
  48. * You must still free the builder even after calling
  49. * this function.
  50. * @param out (out param) On success, the Hadoop messenger.
  51. *
  52. * @return On success, NULL. On error, the error.
  53. */
  54. struct hadoop_err *hrpc_messenger_create(struct hrpc_messenger_builder *bld,
  55. struct hrpc_messenger **out);
  56. /**
  57. * Start an outbound call.
  58. *
  59. * @param msgr The messenger.
  60. * @param call The call.
  61. */
  62. void hrpc_messenger_start_outbound(struct hrpc_messenger *msgr,
  63. struct hrpc_call *call);
  64. /**
  65. * Shut down the messenger.
  66. *
  67. * After this function is called, the messenger will stop accepting new calls.
  68. * We will deliver ESHUTDOWN to existing calls.
  69. *
  70. * @param msgr The messenger.
  71. */
  72. void hrpc_messenger_shutdown(struct hrpc_messenger *msgr);
  73. /**
  74. * De-allocate the memory and other resources associated with this messenger.
  75. *
  76. * After this function is called, the messenger pointer will be invalid.
  77. *
  78. * @param msgr The messenger.
  79. */
  80. void hrpc_messenger_free(struct hrpc_messenger *msgr);
  81. #endif
  82. // vim: ts=4:sw=4:tw=79:et