diff options
author | mustiikhalil <mustii@mmk.one> | 2020-04-06 20:05:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 10:05:56 -0700 |
commit | 9655e12d6d69cd7c651491d9a39db4a7d0644159 (patch) | |
tree | b6d2873b78805724dc69fd92c054f34df558a6c7 | |
parent | fb96fadc20a78da264b1878ff95f12838c3b22c8 (diff) | |
download | flatbuffers-9655e12d6d69cd7c651491d9a39db4a7d0644159.tar.gz flatbuffers-9655e12d6d69cd7c651491d9a39db4a7d0644159.tar.bz2 flatbuffers-9655e12d6d69cd7c651491d9a39db4a7d0644159.zip |
Upgraded swift implementation for grpc (#5843)
Updated version number
-rw-r--r-- | grpc/src/compiler/swift_generator.cc | 6 | ||||
-rw-r--r-- | swift/FlatBuffers.podspec | 2 | ||||
-rw-r--r-- | tests/FlatBuffers.GRPC.Swift/Package.swift | 2 | ||||
-rw-r--r-- | tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.grpc.swift | 6 | ||||
-rw-r--r-- | tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift | 20 | ||||
-rw-r--r-- | tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift | 4 | ||||
-rw-r--r-- | tests/monster_test.grpc.swift | 6 |
7 files changed, 20 insertions, 26 deletions
diff --git a/grpc/src/compiler/swift_generator.cc b/grpc/src/compiler/swift_generator.cc index 7997278b..0a25f6e3 100644 --- a/grpc/src/compiler/swift_generator.cc +++ b/grpc/src/compiler/swift_generator.cc @@ -108,13 +108,13 @@ void GenerateClientClass(const grpc_generator::Service *service, printer->Print(vars, "$ACCESS$ final class $ServiceName$ServiceClient: GRPCClient, " "$ServiceName$Service {\n"); - printer->Print(vars, "\t$ACCESS$ let connection: ClientConnection\n"); + printer->Print(vars, "\t$ACCESS$ let channel: GRPCChannel\n"); printer->Print(vars, "\t$ACCESS$ var defaultCallOptions: CallOptions\n"); printer->Print("\n"); printer->Print(vars, - "\t$ACCESS$ init(connection: ClientConnection, " + "\t$ACCESS$ init(channel: GRPCChannel, " "defaultCallOptions: CallOptions = CallOptions()) {\n"); - printer->Print("\t\tself.connection = connection\n"); + printer->Print("\t\tself.channel = channel\n"); printer->Print("\t\tself.defaultCallOptions = defaultCallOptions\n"); printer->Print("\t}"); printer->Print("\n"); diff --git a/swift/FlatBuffers.podspec b/swift/FlatBuffers.podspec index db877878..6e5f4a08 100644 --- a/swift/FlatBuffers.podspec +++ b/swift/FlatBuffers.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FlatBuffers' - s.version = '0.2.0' + s.version = '0.3.0' s.summary = 'FlatBuffers: Memory Efficient Serialization Library' s.description = "FlatBuffers is a cross platform serialization library architected for diff --git a/tests/FlatBuffers.GRPC.Swift/Package.swift b/tests/FlatBuffers.GRPC.Swift/Package.swift index e9f3bbe4..53250011 100644 --- a/tests/FlatBuffers.GRPC.Swift/Package.swift +++ b/tests/FlatBuffers.GRPC.Swift/Package.swift @@ -12,7 +12,7 @@ let package = Package( dependencies: [ // Main SwiftNIO package .package(path: "../../swift"), - .package(url: "https://github.com/grpc/grpc-swift.git", .branch("nio")) + .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0-alpha.9") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.grpc.swift b/tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.grpc.swift index 6ad1f18d..d337ddfb 100644 --- a/tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.grpc.swift +++ b/tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.grpc.swift @@ -26,11 +26,11 @@ public protocol GreeterService { } public final class GreeterServiceClient: GRPCClient, GreeterService { - public let connection: ClientConnection + public let channel: GRPCChannel public var defaultCallOptions: CallOptions - public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) { - self.connection = connection + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel self.defaultCallOptions = defaultCallOptions } diff --git a/tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift b/tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift index cc9374b2..45915dd9 100644 --- a/tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift +++ b/tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift @@ -31,7 +31,7 @@ func greet(name: String, client greeter: GreeterServiceClient) { // Form the request with the name, if one was provided. var builder = FlatBufferBuilder() let name = builder.create(string: name) - let root = HelloRequest.createHelloRequest(builder, offsetOfName: name) + let root = HelloRequest.createHelloRequest(&builder, offsetOfName: name) builder.finish(offset: root) // Make the RPC call to the server. @@ -45,7 +45,7 @@ func greet(name: String, client greeter: GreeterServiceClient) { } let surname = builder.create(string: "Name") - let manyRoot = ManyHellosRequest.createManyHellosRequest(builder, offsetOfName: surname, numGreetings: 2) + let manyRoot = ManyHellosRequest.createManyHellosRequest(&builder, offsetOfName: surname, numGreetings: 2) builder.finish(offset: manyRoot) let call = greeter.SayManyHellos(Message(builder: &builder)) { message in @@ -80,21 +80,15 @@ func main(args: [String]) { try! group.syncShutdownGracefully() } - // Provide some basic configuration for the connection, in this case we connect to an endpoint on - // localhost at the given port. - let configuration = ClientConnection.Configuration( - target: .hostAndPort("localhost", port), - eventLoopGroup: group - ) - - // Create a connection using the configuration. - let connection = ClientConnection(configuration: configuration) + // Configure the channel, we're not using TLS so the connection is `insecure`. + let channel = ClientConnection.insecure(group: group) + .connect(host: "localhost", port: port) // Provide the connection to the generated client. - let greeter = GreeterServiceClient(connection: connection) + let greeter = GreeterServiceClient(channel: channel) // Do the greeting. - greet(name: "Hello FlatBuffers!", client: greeter) + greet(name: name ?? "Hello FlatBuffers!", client: greeter) } } diff --git a/tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift b/tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift index 5595b640..b361b256 100644 --- a/tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift +++ b/tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift @@ -29,7 +29,7 @@ class Greeter: GreeterProvider { for name in names { var builder = FlatBufferBuilder() let off = builder.create(string: name) - let root = HelloReply.createHelloReply(builder, offsetOfMessage: off) + let root = HelloReply.createHelloReply(&builder, offsetOfMessage: off) builder.finish(offset: root) hellos.append(Message(builder: &builder)) } @@ -43,7 +43,7 @@ class Greeter: GreeterProvider { var builder = FlatBufferBuilder() let off = builder.create(string: recipient) - let root = HelloReply.createHelloReply(builder, offsetOfMessage: off) + let root = HelloReply.createHelloReply(&builder, offsetOfMessage: off) builder.finish(offset: root) return context.eventLoop.makeSucceededFuture(Message<HelloReply>(builder: &builder)) } diff --git a/tests/monster_test.grpc.swift b/tests/monster_test.grpc.swift index 572c0d35..bbb689b3 100644 --- a/tests/monster_test.grpc.swift +++ b/tests/monster_test.grpc.swift @@ -28,11 +28,11 @@ public protocol MonsterStorageService { } public final class MonsterStorageServiceClient: GRPCClient, MonsterStorageService { - public let connection: ClientConnection + public let channel: GRPCChannel public var defaultCallOptions: CallOptions - public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) { - self.connection = connection + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel self.defaultCallOptions = defaultCallOptions } |