create_channel.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. //
  3. // Copyright 2015 gRPC authors.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. //
  18. #ifndef GRPCPP_CREATE_CHANNEL_H
  19. #define GRPCPP_CREATE_CHANNEL_H
  20. #include <memory>
  21. #include <grpcpp/channel.h>
  22. #include <grpcpp/security/credentials.h>
  23. #include <grpcpp/support/channel_arguments.h>
  24. #include <grpcpp/support/client_interceptor.h>
  25. #include <grpcpp/support/config.h>
  26. namespace grpc {
  27. /// Create a new \a Channel pointing to \a target.
  28. ///
  29. /// \param target The URI of the endpoint to connect to.
  30. /// \param creds Credentials to use for the created channel. If it does not
  31. /// hold an object or is invalid, a lame channel (one on which all operations
  32. /// fail) is returned.
  33. std::shared_ptr<Channel> CreateChannel(
  34. const grpc::string& target,
  35. const std::shared_ptr<ChannelCredentials>& creds);
  36. /// Create a new \em custom \a Channel pointing to \a target.
  37. ///
  38. /// \warning For advanced use and testing ONLY. Override default channel
  39. /// arguments only if necessary.
  40. ///
  41. /// \param target The URI of the endpoint to connect to.
  42. /// \param creds Credentials to use for the created channel. If it does not
  43. /// hold an object or is invalid, a lame channel (one on which all operations
  44. /// fail) is returned.
  45. /// \param args Options for channel creation.
  46. std::shared_ptr<Channel> CreateCustomChannel(
  47. const grpc::string& target,
  48. const std::shared_ptr<ChannelCredentials>& creds,
  49. const ChannelArguments& args);
  50. namespace experimental {
  51. /// Create a new \em custom \a Channel pointing to \a target with \a
  52. /// interceptors being invoked per call.
  53. ///
  54. /// \warning For advanced use and testing ONLY. Override default channel
  55. /// arguments only if necessary.
  56. ///
  57. /// \param target The URI of the endpoint to connect to.
  58. /// \param creds Credentials to use for the created channel. If it does not
  59. /// hold an object or is invalid, a lame channel (one on which all operations
  60. /// fail) is returned.
  61. /// \param args Options for channel creation.
  62. std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
  63. const grpc::string& target,
  64. const std::shared_ptr<ChannelCredentials>& creds,
  65. const ChannelArguments& args,
  66. std::vector<
  67. std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
  68. interceptor_creators);
  69. } // namespace experimental
  70. } // namespace grpc
  71. #endif // GRPCPP_CREATE_CHANNEL_H