|
@@ -43,6 +43,7 @@ import Foundation
|
|
|
import gRPC
|
|
import gRPC
|
|
|
//-{% for service in protoFile.service %}
|
|
//-{% for service in protoFile.service %}
|
|
|
|
|
|
|
|
|
|
+/// Type for errors thrown from generated client code.
|
|
|
public enum {{ .|clienterror:protoFile,service }} : Error {
|
|
public enum {{ .|clienterror:protoFile,service }} : Error {
|
|
|
case endOfStream
|
|
case endOfStream
|
|
|
case invalidMessageReceived
|
|
case invalidMessageReceived
|
|
@@ -67,8 +68,12 @@ public enum {{ .|clienterror:protoFile,service }} : Error {
|
|
|
public class {{ protoFile.package|capitalize }}_{{ service.name }}Service {
|
|
public class {{ protoFile.package|capitalize }}_{{ service.name }}Service {
|
|
|
private var channel: Channel
|
|
private var channel: Channel
|
|
|
|
|
|
|
|
|
|
+ /// This metadata will be sent with all requests.
|
|
|
public var metadata : Metadata
|
|
public var metadata : Metadata
|
|
|
|
|
|
|
|
|
|
+ /// 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".
|
|
|
public var host : String {
|
|
public var host : String {
|
|
|
get {
|
|
get {
|
|
|
return self.channel.host
|
|
return self.channel.host
|
|
@@ -78,12 +83,14 @@ public class {{ protoFile.package|capitalize }}_{{ service.name }}Service {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// Create a client that makes insecure connections.
|
|
|
public init(address: String) {
|
|
public init(address: String) {
|
|
|
gRPC.initialize()
|
|
gRPC.initialize()
|
|
|
channel = Channel(address:address)
|
|
channel = Channel(address:address)
|
|
|
metadata = Metadata()
|
|
metadata = Metadata()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// Create a client that makes secure connections.
|
|
|
public init(address: String, certificates: String?, host: String?) {
|
|
public init(address: String, certificates: String?, host: String?) {
|
|
|
gRPC.initialize()
|
|
gRPC.initialize()
|
|
|
channel = Channel(address:address, certificates:certificates, host:host)
|
|
channel = Channel(address:address, certificates:certificates, host:host)
|