Skip to content

Commit

Permalink
Rename "services" to "serviceProviders".
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMage committed Jun 13, 2018
1 parent 98f7fa6 commit a6e8cbb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Examples/EchoXcode/Echo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

// create and start a server for handling insecure requests
insecureServer = ServiceServer(address: "localhost:8081",
services: [echoProvider])
serviceProviders: [echoProvider])
insecureServer.start()

// create and start a server for handling secure requests
Expand All @@ -38,7 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
secureServer = ServiceServer(address: "localhost:8443",
certificateURL: certificateURL,
keyURL: keyURL,
services: [echoProvider])
serviceProviders: [echoProvider])
secureServer.start()
}
}
4 changes: 2 additions & 2 deletions Sources/Examples/Echo/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ Group {
echoServer = ServiceServer(address: address + ":" + port,
certificateURL: certificateURL,
keyURL: keyURL,
services: [EchoProvider()])
serviceProviders: [EchoProvider()])
echoServer?.start()
} else {
print("starting insecure server")
echoServer = ServiceServer(address: address + ":" + port, services: [EchoProvider()])
echoServer = ServiceServer(address: address + ":" + port, serviceProviders: [EchoProvider()])
echoServer?.start()
}
// This blocks to keep the main thread from finishing while the server runs,
Expand Down
12 changes: 6 additions & 6 deletions Sources/SwiftGRPC/Runtime/ServiceServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ open class ServiceServer {
fileprivate let servicesByName: [String: ServiceProvider]

/// Create a server that accepts insecure connections.
public init(address: String, services: [ServiceProvider]) {
public init(address: String, serviceProviders: [ServiceProvider]) {
gRPC.initialize()
self.address = address
server = Server(address: address)
servicesByName = Dictionary(uniqueKeysWithValues: services.map { ($0.serviceName, $0) })
servicesByName = Dictionary(uniqueKeysWithValues: serviceProviders.map { ($0.serviceName, $0) })
}

/// Create a server that accepts secure connections.
public init(address: String, certificateString: String, keyString: String, services: [ServiceProvider]) {
public init(address: String, certificateString: String, keyString: String, serviceProviders: [ServiceProvider]) {
gRPC.initialize()
self.address = address
server = Server(address: address, key: keyString, certs: certificateString)
servicesByName = Dictionary(uniqueKeysWithValues: services.map { ($0.serviceName, $0) })
servicesByName = Dictionary(uniqueKeysWithValues: serviceProviders.map { ($0.serviceName, $0) })
}

/// Create a server that accepts secure connections.
public init?(address: String, certificateURL: URL, keyURL: URL, services: [ServiceProvider]) {
public init?(address: String, certificateURL: URL, keyURL: URL, serviceProviders: [ServiceProvider]) {
guard let certificate = try? String(contentsOf: certificateURL, encoding: .utf8),
let key = try? String(contentsOf: keyURL, encoding: .utf8)
else { return nil }
gRPC.initialize()
self.address = address
server = Server(address: address, key: key, certs: certificate)
servicesByName = Dictionary(uniqueKeysWithValues: services.map { ($0.serviceName, $0) })
servicesByName = Dictionary(uniqueKeysWithValues: serviceProviders.map { ($0.serviceName, $0) })
}

/// Start the server.
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftGRPCTests/BasicEchoTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class BasicEchoTestCase: XCTestCase {
server = ServiceServer(address: address,
certificateString: certificateString,
keyString: String(data: keyForTests, encoding: .utf8)!,
services: [provider])
serviceProviders: [provider])
server.start()
client = Echo_EchoServiceClient(address: address, certificates: certificateString, arguments: [.sslTargetNameOverride("example.com")])
client.host = "example.com"
} else {
server = ServiceServer(address: address, services: [provider])
server = ServiceServer(address: address, serviceProviders: [provider])
server.start()
client = Echo_EchoServiceClient(address: address, secure: false)
}
Expand Down

0 comments on commit a6e8cbb

Please sign in to comment.