ServerHandlerStateMachine+Actions.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2022, 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. #if compiler(>=5.6)
  17. import NIOHPACK
  18. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  19. extension ServerHandlerStateMachine {
  20. enum HandleMetadataAction {
  21. /// Invoke the user handler.
  22. case invokeHandler(Ref<UserInfo>, CallHandlerContext)
  23. /// Cancel the RPC, the metadata was not expected.
  24. case cancel
  25. }
  26. enum HandleMessageAction: Hashable {
  27. /// Forward the message to the interceptors, via the interceptor state machine.
  28. case forward
  29. /// Cancel the RPC, the message was not expected.
  30. case cancel
  31. }
  32. /// The same as 'HandleMessageAction.
  33. typealias HandleEndAction = HandleMessageAction
  34. enum SendMessageAction: Equatable {
  35. /// Intercept the message, but first intercept the headers if they are non-nil. Must go via
  36. /// the interceptor state machine first.
  37. case intercept(headers: HPACKHeaders?)
  38. /// Drop the message.
  39. case drop
  40. }
  41. enum SendStatusAction: Equatable {
  42. /// Intercept the status, providing the given trailers.
  43. case intercept(trailers: HPACKHeaders)
  44. /// Drop the status.
  45. case drop
  46. }
  47. enum CancelAction: Hashable {
  48. /// Cancel and nil out the handler 'bits'.
  49. case cancelAndNilOutHandlerComponents
  50. /// Don't do anything.
  51. case none
  52. }
  53. }
  54. #endif // compiler(>=5.6)