You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

create_channel.h 3.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/impl/codegen/client_interceptor.h>
  23. #include <grpcpp/security/credentials.h>
  24. #include <grpcpp/support/channel_arguments.h>
  25. #include <grpcpp/support/config.h>
  26. namespace grpc
  27. {
  28. /// Create a new \a Channel pointing to \a target.
  29. ///
  30. /// \param target The URI of the endpoint to connect to.
  31. /// \param creds Credentials to use for the created channel. If it does not
  32. /// hold an object or is invalid, a lame channel (one on which all operations
  33. /// fail) is returned.
  34. std::shared_ptr<Channel> CreateChannel(
  35. const grpc::string& target,
  36. const std::shared_ptr<ChannelCredentials>& creds
  37. );
  38. /// Create a new \em custom \a Channel pointing to \a target.
  39. ///
  40. /// \warning For advanced use and testing ONLY. Override default channel
  41. /// arguments only if necessary.
  42. ///
  43. /// \param target The URI of the endpoint to connect to.
  44. /// \param creds Credentials to use for the created channel. If it does not
  45. /// hold an object or is invalid, a lame channel (one on which all operations
  46. /// fail) is returned.
  47. /// \param args Options for channel creation.
  48. std::shared_ptr<Channel> CreateCustomChannel(
  49. const grpc::string& target,
  50. const std::shared_ptr<ChannelCredentials>& creds,
  51. const ChannelArguments& args
  52. );
  53. namespace experimental
  54. {
  55. /// Create a new \em custom \a Channel pointing to \a target with \a
  56. /// interceptors being invoked per call.
  57. ///
  58. /// \warning For advanced use and testing ONLY. Override default channel
  59. /// arguments only if necessary.
  60. ///
  61. /// \param target The URI of the endpoint to connect to.
  62. /// \param creds Credentials to use for the created channel. If it does not
  63. /// hold an object or is invalid, a lame channel (one on which all operations
  64. /// fail) is returned.
  65. /// \param args Options for channel creation.
  66. std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
  67. const grpc::string& target,
  68. const std::shared_ptr<ChannelCredentials>& creds,
  69. const ChannelArguments& args,
  70. std::vector<
  71. std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
  72. interceptor_creators
  73. );
  74. } // namespace experimental
  75. } // namespace grpc
  76. #endif // GRPCPP_CREATE_CHANNEL_H