Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 1 | // Generated GRPC code for FlatBuffers swift! |
| 2 | /// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift |
| 3 | /// in case of an issue please open github issue, though it would be maintained |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 4 | |
| 5 | // swiftlint:disable all |
| 6 | // swiftformat:disable all |
| 7 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 8 | import Foundation |
| 9 | import GRPC |
| 10 | import NIO |
| 11 | import NIOHTTP1 |
| 12 | import FlatBuffers |
| 13 | |
| 14 | public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {} |
| 15 | public extension GRPCFlatBufPayload { |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 16 | init(serializedByteBuffer: inout NIO.ByteBuffer) throws { |
| 17 | self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes)) |
| 18 | } |
| 19 | func serialize(into buffer: inout NIO.ByteBuffer) throws { |
| 20 | let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size)) |
| 21 | buffer.writeBytes(buf) |
| 22 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 23 | } |
| 24 | extension Message: GRPCFlatBufPayload {} |
| 25 | |
| 26 | /// Usage: instantiate MyGame_Example_MonsterStorageServiceClient, then call methods of this protocol to make API calls. |
| 27 | public protocol MyGame_Example_MonsterStorageService { |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 28 | func Store(_ request: Message<MyGame_Example_Monster>, callOptions: CallOptions?) -> UnaryCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> |
| 29 | func Retrieve(_ request: Message<MyGame_Example_Stat>, callOptions: CallOptions?, handler: @escaping (Message<MyGame_Example_Monster>) -> Void) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> |
| 30 | func GetMaxHitPoint(callOptions: CallOptions?) -> ClientStreamingCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> |
| 31 | func GetMinMaxHitPoints(callOptions: CallOptions?, handler: @escaping (Message<MyGame_Example_Stat>) -> Void) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | public final class MyGame_Example_MonsterStorageServiceClient: GRPCClient, MyGame_Example_MonsterStorageService { |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 35 | public let channel: GRPCChannel |
| 36 | public var defaultCallOptions: CallOptions |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 37 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 38 | public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { |
| 39 | self.channel = channel |
| 40 | self.defaultCallOptions = defaultCallOptions |
| 41 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 42 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 43 | public func Store(_ request: Message<MyGame_Example_Monster>, callOptions: CallOptions? = nil) -> UnaryCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> { |
| 44 | return self.makeUnaryCall(path: "/MyGame.Example.MonsterStorage/Store", request: request, callOptions: callOptions ?? self.defaultCallOptions) |
| 45 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 46 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 47 | public func Retrieve(_ request: Message<MyGame_Example_Stat>, callOptions: CallOptions? = nil, handler: @escaping (Message<MyGame_Example_Monster>) -> Void) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> { |
| 48 | return self.makeServerStreamingCall(path: "/MyGame.Example.MonsterStorage/Retrieve", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler) |
| 49 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 50 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 51 | public func GetMaxHitPoint(callOptions: CallOptions? = nil) -> ClientStreamingCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> { |
| 52 | return self.makeClientStreamingCall(path: "/MyGame.Example.MonsterStorage/GetMaxHitPoint", callOptions: callOptions ?? self.defaultCallOptions) |
| 53 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 54 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 55 | public func GetMinMaxHitPoints(callOptions: CallOptions? = nil, handler: @escaping (Message<MyGame_Example_Stat>) -> Void) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> { |
| 56 | return self.makeBidirectionalStreamingCall(path: "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints", callOptions: callOptions ?? self.defaultCallOptions, handler: handler) |
| 57 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | public protocol MyGame_Example_MonsterStorageProvider: CallHandlerProvider { |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 61 | func Store(_ request: Message<MyGame_Example_Monster>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<MyGame_Example_Stat>> |
| 62 | func Retrieve(request: Message<MyGame_Example_Stat>, context: StreamingResponseCallContext<Message<MyGame_Example_Monster>>) -> EventLoopFuture<GRPCStatus> |
| 63 | func GetMaxHitPoint(context: UnaryResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void> |
| 64 | func GetMinMaxHitPoints(context: StreamingResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void> |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | public extension MyGame_Example_MonsterStorageProvider { |
| 68 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 69 | var serviceName: Substring { return "MyGame.Example.MonsterStorage" } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 70 | |
Austin Schuh | 58b9b47 | 2020-11-25 19:12:44 -0800 | [diff] [blame^] | 71 | func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { |
| 72 | switch methodName { |
| 73 | case "Store": |
| 74 | return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in |
| 75 | return { request in |
| 76 | self.Store(request, context: context) |
| 77 | } |
| 78 | } |
| 79 | case "Retrieve": |
| 80 | return CallHandlerFactory.makeServerStreaming(callHandlerContext: callHandlerContext) { context in |
| 81 | return { request in |
| 82 | self.Retrieve(request: request, context: context) |
| 83 | } |
| 84 | } |
| 85 | case "GetMaxHitPoint": |
| 86 | return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in |
| 87 | self.GetMaxHitPoint(context: context) |
| 88 | } |
| 89 | case "GetMinMaxHitPoints": |
| 90 | return CallHandlerFactory.makeBidirectionalStreaming(callHandlerContext: callHandlerContext) { context in |
| 91 | self.GetMinMaxHitPoints(context: context) |
| 92 | } |
| 93 | default: return nil; |
| 94 | } |
| 95 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 96 | |
| 97 | } |