blob: b5fd53596a8398e1cf1180ea652f0a577b2afb28 [file] [log] [blame]
Austin Schuh272c6132020-11-14 16:37:52 -08001// 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 Schuh58b9b472020-11-25 19:12:44 -08004
5// swiftlint:disable all
6// swiftformat:disable all
7
Austin Schuh272c6132020-11-14 16:37:52 -08008import Foundation
9import GRPC
10import NIO
11import NIOHTTP1
12import FlatBuffers
13
14public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {}
15public extension GRPCFlatBufPayload {
Austin Schuh58b9b472020-11-25 19:12:44 -080016 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 Schuh272c6132020-11-14 16:37:52 -080023}
24extension Message: GRPCFlatBufPayload {}
25
26/// Usage: instantiate MyGame_Example_MonsterStorageServiceClient, then call methods of this protocol to make API calls.
James Kuszmaul8e62b022022-03-22 09:33:25 -070027public protocol MyGame_Example_MonsterStorageClientProtocol: GRPCClient {
28
29 var serviceName: String { get }
30
31 var interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? { get }
32
33 func Store(
34 _ request: Message<MyGame_Example_Monster>
35 , callOptions: CallOptions?
36 ) -> UnaryCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
37
38 func Retrieve(
39 _ request: Message<MyGame_Example_Stat>
40 , callOptions: CallOptions?,
41 handler: @escaping (Message<MyGame_Example_Monster>) -> Void
42 ) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>
43
44 func GetMaxHitPoint(
45 callOptions: CallOptions?
46 ) -> ClientStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
47
48 func GetMinMaxHitPoints(
49 callOptions: CallOptions?,
50 handler: @escaping (Message<MyGame_Example_Stat> ) -> Void
51 ) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
52
Austin Schuh272c6132020-11-14 16:37:52 -080053}
54
James Kuszmaul8e62b022022-03-22 09:33:25 -070055extension MyGame_Example_MonsterStorageClientProtocol {
56
57 public var serviceName: String { "MyGame.Example.MonsterStorage" }
58
59 public func Store(
60 _ request: Message<MyGame_Example_Monster>
61 , callOptions: CallOptions? = nil
62 ) -> UnaryCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
63 return self.makeUnaryCall(
64 path: "/MyGame.Example.MonsterStorage/Store",
65 request: request,
66 callOptions: callOptions ?? self.defaultCallOptions,
67 interceptors: self.interceptors?.makeStoreInterceptors() ?? []
68 )
69 }
70
71 public func Retrieve(
72 _ request: Message<MyGame_Example_Stat>
73 , callOptions: CallOptions? = nil,
74 handler: @escaping (Message<MyGame_Example_Monster>) -> Void
75 ) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> {
76 return self.makeServerStreamingCall(
77 path: "/MyGame.Example.MonsterStorage/Retrieve",
78 request: request,
79 callOptions: callOptions ?? self.defaultCallOptions,
80 interceptors: self.interceptors?.makeRetrieveInterceptors() ?? [],
81 handler: handler
82 )
83 }
84
85 public func GetMaxHitPoint(
86 callOptions: CallOptions? = nil
87 ) -> ClientStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
88 return self.makeClientStreamingCall(
89 path: "/MyGame.Example.MonsterStorage/GetMaxHitPoint",
90 callOptions: callOptions ?? self.defaultCallOptions,
91 interceptors: self.interceptors?.makeGetMaxHitPointInterceptors() ?? []
92 )
93 }
94
95 public func GetMinMaxHitPoints(
96 callOptions: CallOptions? = nil,
97 handler: @escaping (Message<MyGame_Example_Stat> ) -> Void
98 ) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
99 return self.makeBidirectionalStreamingCall(
100 path: "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
101 callOptions: callOptions ?? self.defaultCallOptions,
102 interceptors: self.interceptors?.makeGetMinMaxHitPointsInterceptors() ?? [],
103 handler: handler
104 )
105 }
106}
107
108public protocol MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol {
109 /// - Returns: Interceptors to use when invoking 'Store'.
110 func makeStoreInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
111
112 /// - Returns: Interceptors to use when invoking 'Retrieve'.
113 func makeRetrieveInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>]
114
115 /// - Returns: Interceptors to use when invoking 'GetMaxHitPoint'.
116 func makeGetMaxHitPointInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
117
118 /// - Returns: Interceptors to use when invoking 'GetMinMaxHitPoints'.
119 func makeGetMinMaxHitPointsInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
120
121}
122
123public final class MyGame_Example_MonsterStorageServiceClient: MyGame_Example_MonsterStorageClientProtocol {
Austin Schuh58b9b472020-11-25 19:12:44 -0800124 public let channel: GRPCChannel
125 public var defaultCallOptions: CallOptions
James Kuszmaul8e62b022022-03-22 09:33:25 -0700126 public var interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol?
Austin Schuh272c6132020-11-14 16:37:52 -0800127
James Kuszmaul8e62b022022-03-22 09:33:25 -0700128 public init(
129 channel: GRPCChannel,
130 defaultCallOptions: CallOptions = CallOptions(),
131 interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? = nil
132 ) {
Austin Schuh58b9b472020-11-25 19:12:44 -0800133 self.channel = channel
134 self.defaultCallOptions = defaultCallOptions
James Kuszmaul8e62b022022-03-22 09:33:25 -0700135 self.interceptors = interceptors
Austin Schuh58b9b472020-11-25 19:12:44 -0800136 }
Austin Schuh272c6132020-11-14 16:37:52 -0800137}
138
139public protocol MyGame_Example_MonsterStorageProvider: CallHandlerProvider {
James Kuszmaul8e62b022022-03-22 09:33:25 -0700140 var interceptors: MyGame_Example_MonsterStorageServerInterceptorFactoryProtocol? { get }
141 func Store(request: Message<MyGame_Example_Monster>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<MyGame_Example_Stat>>
Austin Schuh58b9b472020-11-25 19:12:44 -0800142 func Retrieve(request: Message<MyGame_Example_Stat>, context: StreamingResponseCallContext<Message<MyGame_Example_Monster>>) -> EventLoopFuture<GRPCStatus>
143 func GetMaxHitPoint(context: UnaryResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
144 func GetMinMaxHitPoints(context: StreamingResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
Austin Schuh272c6132020-11-14 16:37:52 -0800145}
146
147public extension MyGame_Example_MonsterStorageProvider {
148
Austin Schuh58b9b472020-11-25 19:12:44 -0800149 var serviceName: Substring { return "MyGame.Example.MonsterStorage" }
Austin Schuh272c6132020-11-14 16:37:52 -0800150
James Kuszmaul8e62b022022-03-22 09:33:25 -0700151 func handle(method name: Substring, context: CallHandlerContext) -> GRPCServerHandlerProtocol? {
152 switch name {
Austin Schuh58b9b472020-11-25 19:12:44 -0800153 case "Store":
James Kuszmaul8e62b022022-03-22 09:33:25 -0700154 return UnaryServerHandler(
155 context: context,
156 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(),
157 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(),
158 interceptors: self.interceptors?.makeStoreInterceptors() ?? [],
159 userFunction: self.Store(request:context:))
160
Austin Schuh58b9b472020-11-25 19:12:44 -0800161 case "Retrieve":
James Kuszmaul8e62b022022-03-22 09:33:25 -0700162 return ServerStreamingServerHandler(
163 context: context,
164 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Stat>>(),
165 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Monster>>(),
166 interceptors: self.interceptors?.makeRetrieveInterceptors() ?? [],
167 userFunction: self.Retrieve(request:context:))
168
Austin Schuh58b9b472020-11-25 19:12:44 -0800169 case "GetMaxHitPoint":
James Kuszmaul8e62b022022-03-22 09:33:25 -0700170 return ClientStreamingServerHandler(
171 context: context,
172 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(),
173 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(),
174 interceptors: self.interceptors?.makeGetMaxHitPointInterceptors() ?? [],
175 observerFactory: self.GetMaxHitPoint(context:))
176
Austin Schuh58b9b472020-11-25 19:12:44 -0800177 case "GetMinMaxHitPoints":
James Kuszmaul8e62b022022-03-22 09:33:25 -0700178 return BidirectionalStreamingServerHandler(
179 context: context,
180 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(),
181 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(),
182 interceptors: self.interceptors?.makeGetMinMaxHitPointsInterceptors() ?? [],
183 observerFactory: self.GetMinMaxHitPoints(context:))
184
Austin Schuh58b9b472020-11-25 19:12:44 -0800185 default: return nil;
186 }
187 }
Austin Schuh272c6132020-11-14 16:37:52 -0800188
189}
James Kuszmaul8e62b022022-03-22 09:33:25 -0700190
191public protocol MyGame_Example_MonsterStorageServerInterceptorFactoryProtocol {
192 /// - Returns: Interceptors to use when handling 'Store'.
193 /// Defaults to calling `self.makeInterceptors()`.
194 func makeStoreInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
195
196 /// - Returns: Interceptors to use when handling 'Retrieve'.
197 /// Defaults to calling `self.makeInterceptors()`.
198 func makeRetrieveInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>]
199
200 /// - Returns: Interceptors to use when handling 'GetMaxHitPoint'.
201 /// Defaults to calling `self.makeInterceptors()`.
202 func makeGetMaxHitPointInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
203
204 /// - Returns: Interceptors to use when handling 'GetMinMaxHitPoints'.
205 /// Defaults to calling `self.makeInterceptors()`.
206 func makeGetMinMaxHitPointsInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>]
207
208}