RequestMaker.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2020, 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. import GRPC
  17. import Logging
  18. import NIOCore
  19. /// Implement to provide a method of making requests to a server from a client.
  20. protocol RequestMaker {
  21. /// Initialiser to gather requirements.
  22. /// - Parameters:
  23. /// - config: config from the driver describing what to do.
  24. /// - client: client interface to the server.
  25. /// - requestMessage: Pre-made request message to use possibly repeatedly.
  26. /// - logger: Where to log useful diagnostics.
  27. /// - stats: Where to record statistics on latency.
  28. init(
  29. config: Grpc_Testing_ClientConfig,
  30. client: Grpc_Testing_BenchmarkServiceClient,
  31. requestMessage: Grpc_Testing_SimpleRequest,
  32. logger: Logger,
  33. stats: StatsWithLock
  34. )
  35. /// Initiate a request sequence to the server.
  36. /// - returns: A future which completes when the request-response sequence is complete.
  37. func makeRequest() -> EventLoopFuture<GRPCStatus>
  38. /// Request termination of the request-response sequence.
  39. func requestStop()
  40. }