GRPCStreamRequest

public class GRPCStreamRequest<RequestModel, ResponseModel> : GRPCRequestType where RequestModel : GRPCModel, ResponseModel : GRPCModel

Undocumented

Public Attributes

  • Vapor Request from which the gRPC request was instantiated. This reference is required by the GRPCRequestType protocol.

    Declaration

    Swift

    public var vaporRequest: Request

Client Streaming Methods

  • Handles incoming messages from the messageStream by calling the passed closure for each of these messages. It calls the closure for the next message as soon as the next message arrived.

    Declaration

    Swift

    public func forEach(onNext: @escaping ((RequestModel) -> Void)) -> EventLoopFuture<Void>

    Parameters

    onNext

    A closure that gets a single RequestModel value to handle from the stream and returns Void

    Return Value

    A succeeded future of the type Void that succeeds when the stream has ended and the forEach method has been called for every message.

  • Collects incoming messages from the messageStreamand returns a future with an array of the collected RequestModels.

    Declaration

    Swift

    public func collect() -> EventLoopFuture<[RequestModel]>

    Return Value

    A succeeded future of the type [RequestModel] that succeeds with an array of every incoming messages once the stream has ended.

Server Streaming Methods

  • Sends a response of type ResponseModel by succeeding the promise of the previous message with the response message value and a promise for the next stream message.

    Declaration

    Swift

    public func sendResponse(message: ResponseModel)

    Parameters

    message

    Single outgoing ResponseModel object which will be sent as a response.

  • Undocumented

    Declaration

    Swift

    public func sendEnd()

Client Streaming Methods

  • Undocumented

    Declaration

    Swift

    public func respondforEach(onNext: @escaping ((RequestModel) -> ResponseModel))