Pārlūkot izejas kodu

Update plugin and examples to use 0.3.0 client-creation interface.

Tim Burks 8 gadi atpakaļ
vecāks
revīzija
c862de3a12

+ 1 - 1
Examples/Datastore/PackageManager/Package.swift

@@ -17,7 +17,7 @@ import PackageDescription
 let package = Package (
     name: "Datastore",
     dependencies: [
-        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,2,5)),
+        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,3,0)),
         .Package(url: "https://github.com/apple/swift-protobuf.git", Version(1,0,2)),
         .Package(url: "https://github.com/google/auth-library-swift.git", Version(0,3,4)),
 	.Package(url: "https://github.com/kylef/Commander.git", Version(0,8,0)),

+ 1 - 3
Examples/Datastore/PackageManager/Sources/main.swift

@@ -63,9 +63,7 @@ func prepareService() throws -> Google_Datastore_V1_DatastoreService? {
   }
   // Initialize gRPC service
   gRPC.initialize()
-  let service = Google_Datastore_V1_DatastoreService(address:"datastore.googleapis.com",
-                                                     certificates:nil,
-                                                     host:nil)
+  let service = Google_Datastore_V1_DatastoreService(address:"datastore.googleapis.com")
   service.metadata = Metadata(["authorization":"Bearer " + authToken])
   return service
 }

+ 5 - 5
Examples/Echo/Generated/echo.client.pb.swift

@@ -318,15 +318,15 @@ internal class Echo_EchoService {
     }
   }
 
-  /// Create a client that makes insecure connections.
-  internal init(address: String) {
+  /// Create a client.
+  internal init(address: String, secure: Bool = true) {
     gRPC.initialize()
-    channel = Channel(address:address)
+    channel = Channel(address:address, secure:secure)
     metadata = Metadata()
   }
 
-  /// Create a client that makes secure connections.
-  internal init(address: String, certificates: String?, host: String?) {
+  /// Create a client that makes secure connections with a custom certificate and (optional) hostname.
+  internal init(address: String, certificates: String, host: String?) {
     gRPC.initialize()
     channel = Channel(address:address, certificates:certificates, host:host)
     metadata = Metadata()

+ 1 - 1
Examples/Echo/PackageManager/Package.swift

@@ -17,7 +17,7 @@ import PackageDescription
 let package = Package (
     name: "Echo",
     dependencies: [
-        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,2,5)),
+        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,3,0)),
         .Package(url: "https://github.com/apple/swift-protobuf.git", Version(1,0,2)),
     ]
 )

+ 1 - 1
Examples/Echo/PackageManager/Sources/main.swift

@@ -120,7 +120,7 @@ if client != "" {
       service = Echo_EchoService(address:address + ":" + port, certificates:certificates, host:"example.com")
       service.host = "example.com" // sample override
     } else {
-      service = Echo_EchoService(address:address + ":" + port)
+      service = Echo_EchoService(address:address + ":" + port, secure:false)
     }
 
     service.metadata = Metadata(["x-goog-api-key":"YOUR_API_KEY",

+ 1 - 1
Examples/NaturalLanguage/PackageManager/Package.swift

@@ -17,7 +17,7 @@ import PackageDescription
 let package = Package (
     name: "NaturalLanguage",
     dependencies: [
-        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,2,5)),
+        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,3,0)),
         .Package(url: "https://github.com/apple/swift-protobuf.git", Version(1,0,2)),
         .Package(url: "https://github.com/google/auth-library-swift.git", Version(0,3,4)),
     ]

+ 1 - 3
Examples/NaturalLanguage/PackageManager/Sources/main.swift

@@ -31,9 +31,7 @@ if let provider = DefaultTokenProvider(scopes: scopes) {
         exit(-1)
       }
 
-      let service = Google_Cloud_Language_V1_LanguageServiceService(address:"language.googleapis.com",
-                                                                    certificates:nil,
-                                                                    host:nil)
+      let service = Google_Cloud_Language_V1_LanguageServiceService(address:"language.googleapis.com")
 
       service.metadata = Metadata(["authorization":"Bearer " + authToken])
 

+ 1 - 1
Examples/Simple/PackageManager/Package.swift

@@ -17,6 +17,6 @@ import PackageDescription
 let package = Package (
     name: "Simple",
     dependencies: [
-        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,2,5)),
+        .Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,3,0)),
     ]
 )

+ 1 - 1
Examples/Simple/PackageManager/main.swift

@@ -44,7 +44,7 @@ func main() throws {
 
 func client() throws {
   let message = "hello, server!".data(using: .utf8)
-  let c = gRPC.Channel(address:address)
+  let c = gRPC.Channel(address:address, secure:false)
   let steps = 3
   for i in 0..<steps {
     let latch = CountDownLatch(1)

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
Plugin/Sources/protoc-gen-swiftgrpc/templates.swift


+ 5 - 5
Plugin/Templates/client.pb.swift

@@ -67,15 +67,15 @@ import SwiftProtobuf
     }
   }
 
-  /// Create a client that makes insecure connections.
-  {{ access }} init(address: String) {
+  /// Create a client.
+  {{ access }} init(address: String, secure: Bool = true) {
     gRPC.initialize()
-    channel = Channel(address:address)
+    channel = Channel(address:address, secure:secure)
     metadata = Metadata()
   }
 
-  /// Create a client that makes secure connections.
-  {{ access }} init(address: String, certificates: String?, host: String?) {
+  /// Create a client that makes secure connections with a custom certificate and (optional) hostname.
+  {{ access }} init(address: String, certificates: String, host: String?) {
     gRPC.initialize()
     channel = Channel(address:address, certificates:certificates, host:host)
     metadata = Metadata()

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels