MethodDescriptor.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2023, gRPC Authors All rights reserved.
  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. */
  16. /// A description of a method on a service.
  17. public struct MethodDescriptor: Sendable, Hashable {
  18. /// The name of the service, including the package name.
  19. ///
  20. /// For example, the name of the "Greeter" service in "helloworld" package
  21. /// is "helloworld.Greeter".
  22. public var service: String
  23. /// The name of the method in the service, excluding the service name.
  24. public var method: String
  25. /// The fully qualified method name in the format "package.service/method".
  26. ///
  27. /// For example, the fully qualified name of the "SayHello" method of the "Greeter" service in
  28. /// "helloworld" package is "helloworld.Greeter/SayHelllo".
  29. public var fullyQualifiedMethod: String {
  30. "\(self.service)/\(self.method)"
  31. }
  32. /// Creates a new method descriptor.
  33. ///
  34. /// - Parameters:
  35. /// - service: The name of the service, including the package name. For example,
  36. /// "helloworld.Greeter".
  37. /// - method: The name of the method. For example, "SayHello".
  38. public init(service: String, method: String) {
  39. self.service = service
  40. self.method = method
  41. }
  42. }