ChannelBase.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #region Copyright notice and license
  2. // Copyright 2019 The gRPC Authors
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System;
  17. using Grpc.Core.Utils;
  18. namespace Grpc.Core
  19. {
  20. /// <summary>
  21. /// Base class for gRPC channel. Channels are an abstraction of long-lived connections to remote servers.
  22. /// </summary>
  23. public abstract class ChannelBase
  24. {
  25. private readonly string target;
  26. /// <summary>
  27. /// Initializes a new instance of <see cref="ChannelBase"/> class that connects to a specific host.
  28. /// </summary>
  29. /// <param name="target">Target of the channel.</param>
  30. protected ChannelBase(string target)
  31. {
  32. this.target = GrpcPreconditions.CheckNotNull(target, nameof(target));
  33. }
  34. /// <summary>The original target used to create the channel.</summary>
  35. public string Target
  36. {
  37. get { return this.target; }
  38. }
  39. /// <summary>
  40. /// Create a new <see cref="CallInvoker"/> for the channel.
  41. /// </summary>
  42. /// <returns>A new <see cref="CallInvoker"/>.</returns>
  43. public abstract CallInvoker CreateCallInvoker();
  44. }
  45. }