Browse Source

More `swiftformat`.

Daniel Alm 7 years ago
parent
commit
b366d54ac0

+ 24 - 24
Sources/gRPC/GenCodeSupport/ServiceClient.swift

@@ -20,41 +20,41 @@ import SwiftProtobuf
 
 public protocol ServiceClient {
   var channel: Channel { get }
-  
+
   /// This metadata will be sent with all requests.
   var metadata: Metadata { get }
-  
+
   /// This property allows the service host name to be overridden.
   /// For example, it can be used to make calls to "localhost:8080"
   /// appear to be to "example.com".
-  var host : String { get }
-  
+  var host: String { get }
+
   /// This property allows the service timeout to be overridden.
-  var timeout : TimeInterval { get }
+  var timeout: TimeInterval { get }
 }
 
 open class ServiceClientBase: ServiceClient {
   public let channel: Channel
-  
+
   public var metadata: Metadata
-  
+
   public var host: String {
-    get { return self.channel.host }
-    set { self.channel.host = newValue }
+    get { return channel.host }
+    set { channel.host = newValue }
   }
-  
+
   public var timeout: TimeInterval {
-    get { return self.channel.timeout }
-    set { self.channel.timeout = newValue }
+    get { return channel.timeout }
+    set { channel.timeout = newValue }
   }
-  
+
   /// Create a client.
   public init(address: String, secure: Bool = true) {
     gRPC.initialize()
     channel = Channel(address: address, secure: secure)
     metadata = Metadata()
   }
-  
+
   /// Create a client that makes secure connections with a custom certificate and (optional) hostname.
   public init(address: String, certificates: String, host: String?) {
     gRPC.initialize()
@@ -68,26 +68,26 @@ open class ServiceClientBase: ServiceClient {
 /// Note: completion blocks are NOT called with this default implementation, and asynchronous unary calls are NOT implemented!
 open class ServiceClientTestStubBase: ServiceClient {
   open private(set) var channel: Channel
-  
-  open var metadata : Metadata
-  
-  open var host : String {
+
+  open var metadata: Metadata
+
+  open var host: String {
     get { return self.channel.host }
     set { self.channel.host = newValue }
   }
-  
-  open var timeout : TimeInterval {
-    get { return self.channel.timeout }
-    set { self.channel.timeout = newValue }
+
+  open var timeout: TimeInterval {
+    get { return channel.timeout }
+    set { channel.timeout = newValue }
   }
-  
+
   /// Create a client.
   public init(address: String, secure: Bool = true) {
     gRPC.initialize()
     channel = Channel(address: address, secure: secure)
     metadata = Metadata()
   }
-  
+
   /// Create a client that makes secure connections with a custom certificate and (optional) hostname.
   public init(address: String, certificates: String, host: String?) {
     gRPC.initialize()

+ 11 - 11
Sources/gRPC/GenCodeSupport/ServiceServer.swift

@@ -21,28 +21,28 @@ import SwiftProtobuf
 open class ServiceServer {
   public let address: String
   public let server: Server
-  
+
   /// Create a server that accepts insecure connections.
   public init(address: String) {
     gRPC.initialize()
     self.address = address
-    self.server = Server(address: address)
+    server = Server(address: address)
   }
-  
+
   /// Create a server that accepts secure connections.
-  public init?(address:String, certificateURL: URL, keyURL: URL) {
+  public init?(address: String, certificateURL: URL, keyURL: URL) {
     gRPC.initialize()
     self.address = address
     guard let certificate = try? String(contentsOf: certificateURL, encoding: .utf8),
       let key = try? String(contentsOf: keyURL, encoding: .utf8)
-      else { return nil }
-    self.server = Server(address: address, key: key, certs: certificate)
+    else { return nil }
+    server = Server(address: address, key: key, certs: certificate)
   }
-  
+
   /// Handle the given method. Needs to be overridden by actual implementations.
   /// Returns whether the method was actually handled.
   open func handleMethod(_ method: String, handler: Handler, queue: DispatchQueue) throws -> Bool { fatalError("needs to be overridden") }
-  
+
   /// Start the server.
   public func start(queue: DispatchQueue = DispatchQueue.global()) {
     server.run { [weak self] handler in
@@ -50,7 +50,7 @@ open class ServiceServer {
         print("ERROR: ServiceServer has been asked to handle a request even though it has already been deallocated")
         return
       }
-      
+
       let unwrappedHost = handler.host ?? "(nil)"
       let unwrappedMethod = handler.method ?? "(nil)"
       let unwrappedCaller = handler.caller ?? "(nil)"
@@ -58,11 +58,11 @@ open class ServiceServer {
         + " calling " + unwrappedMethod
         + " from " + unwrappedCaller
         + " with " + handler.requestMetadata.description)
-      
+
       do {
         if try !strongSelf.handleMethod(unwrappedMethod, handler: handler, queue: queue) {
           // handle unknown requests
-          try handler.receiveMessage(initialMetadata:Metadata()) {(requestData) in
+          try handler.receiveMessage(initialMetadata: Metadata()) { _ in
             try handler.sendResponse(statusCode: .unimplemented,
                                      statusMessage: "unknown method " + unwrappedMethod,
                                      trailingMetadata: Metadata())