Files
flatbuffers/tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.grpc.swift
mustiikhalil 815d3e820d Upgrade swift grpc to alpha 24 (#6439)
Upgrade swift grpc to alpha 24
2021-02-04 02:01:18 +03:00

146 lines
5.2 KiB
Swift

// Generated GRPC code for FlatBuffers swift!
/// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift
/// in case of an issue please open github issue, though it would be maintained
// swiftlint:disable all
// swiftformat:disable all
import Foundation
import GRPC
import NIO
import NIOHTTP1
import FlatBuffers
public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {}
public extension GRPCFlatBufPayload {
init(serializedByteBuffer: inout NIO.ByteBuffer) throws {
self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes))
}
func serialize(into buffer: inout NIO.ByteBuffer) throws {
let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size))
buffer.writeBytes(buf)
}
}
extension Message: GRPCFlatBufPayload {}
/// Usage: instantiate GreeterServiceClient, then call methods of this protocol to make API calls.
public protocol GreeterClientProtocol: GRPCClient {
var serviceName: String { get }
var interceptors: GreeterClientInterceptorFactoryProtocol? { get }
func SayHello(
_ request: Message<HelloRequest>
, callOptions: CallOptions?
) -> UnaryCall<Message<HelloRequest>, Message<HelloReply>>
func SayManyHellos(
_ request: Message<ManyHellosRequest>
, callOptions: CallOptions?,
handler: @escaping (Message<HelloReply>) -> Void
) -> ServerStreamingCall<Message<ManyHellosRequest>, Message<HelloReply>>
}
extension GreeterClientProtocol {
public var serviceName: String { "Greeter" }
public func SayHello(
_ request: Message<HelloRequest>
, callOptions: CallOptions? = nil
) -> UnaryCall<Message<HelloRequest>, Message<HelloReply>> {
return self.makeUnaryCall(
path: "/Greeter/SayHello",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeSayHelloInterceptors() ?? []
)
}
public func SayManyHellos(
_ request: Message<ManyHellosRequest>
, callOptions: CallOptions? = nil,
handler: @escaping (Message<HelloReply>) -> Void
) -> ServerStreamingCall<Message<ManyHellosRequest>, Message<HelloReply>> {
return self.makeServerStreamingCall(
path: "/Greeter/SayManyHellos",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeSayManyHellosInterceptors() ?? [],
handler: handler
)
}
}
public protocol GreeterClientInterceptorFactoryProtocol {
/// - Returns: Interceptors to use when invoking 'SayHello'.
func makeSayHelloInterceptors() -> [ClientInterceptor<Message<HelloRequest>, Message<HelloReply>>]
/// - Returns: Interceptors to use when invoking 'SayManyHellos'.
func makeSayManyHellosInterceptors() -> [ClientInterceptor<Message<ManyHellosRequest>, Message<HelloReply>>]
}
public final class GreeterServiceClient: GreeterClientProtocol {
public let channel: GRPCChannel
public var defaultCallOptions: CallOptions
public var interceptors: GreeterClientInterceptorFactoryProtocol?
public init(
channel: GRPCChannel,
defaultCallOptions: CallOptions = CallOptions(),
interceptors: GreeterClientInterceptorFactoryProtocol? = nil
) {
self.channel = channel
self.defaultCallOptions = defaultCallOptions
self.interceptors = interceptors
}
}
public protocol GreeterProvider: CallHandlerProvider {
var interceptors: GreeterServerInterceptorFactoryProtocol? { get }
func SayHello(request: Message<HelloRequest>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<HelloReply>>
func SayManyHellos(request: Message<ManyHellosRequest>, context: StreamingResponseCallContext<Message<HelloReply>>) -> EventLoopFuture<GRPCStatus>
}
public extension GreeterProvider {
var serviceName: Substring { return "Greeter" }
func handle(method name: Substring, context: CallHandlerContext) -> GRPCServerHandlerProtocol? {
switch name {
case "SayHello":
return UnaryServerHandler(
context: context,
requestDeserializer: GRPCPayloadDeserializer<Message<HelloRequest>>(),
responseSerializer: GRPCPayloadSerializer<Message<HelloReply>>(),
interceptors: self.interceptors?.makeSayHelloInterceptors() ?? [],
userFunction: self.SayHello(request:context:))
case "SayManyHellos":
return ServerStreamingServerHandler(
context: context,
requestDeserializer: GRPCPayloadDeserializer<Message<ManyHellosRequest>>(),
responseSerializer: GRPCPayloadSerializer<Message<HelloReply>>(),
interceptors: self.interceptors?.makeSayManyHellosInterceptors() ?? [],
userFunction: self.SayManyHellos(request:context:))
default: return nil;
}
}
}
public protocol GreeterServerInterceptorFactoryProtocol {
/// - Returns: Interceptors to use when handling 'SayHello'.
/// Defaults to calling `self.makeInterceptors()`.
func makeSayHelloInterceptors() -> [ServerInterceptor<Message<HelloRequest>, Message<HelloReply>>]
/// - Returns: Interceptors to use when handling 'SayManyHellos'.
/// Defaults to calling `self.makeInterceptors()`.
func makeSayManyHellosInterceptors() -> [ServerInterceptor<Message<ManyHellosRequest>, Message<HelloReply>>]
}