Skip to content

Commit

Permalink
Merge branch 'master' into update-grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
timburks authored Jun 4, 2018
2 parents 4a16c13 + 38b66c3 commit e791f85
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
UNAME_S = $(shell uname -s)

CFLAGS = -Xcc -ISources/BoringSSL/include
ifeq ($(UNAME_S),Linux)
CFLAGS = -Xcc -DTSI_OPENSSL_ALPN_SUPPORT=0
else
CFLAGS = -Xcc -ISources/BoringSSL/include
endif

all:
swift build -v $(CFLAGS)
Expand Down
35 changes: 29 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,44 @@
*/
import PackageDescription

var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.0.2"),
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0")
]

var cGRPCDependencies: [Target.Dependency] = []
#if os(Linux)
// On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
// See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
dependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
#else
cGRPCDependencies.append("BoringSSL")
#endif

/*
* `swift-nio-zlib-support` uses `pkgConfig` to find `zlib` on
* non-Apple platforms. Details here:
* https://github.com/apple/swift-nio-zlib-support/issues/2#issuecomment-384681975
*
* This doesn't play well with Macports, so require it only for non-Apple
* platforms, until there is a better solution.
* Issue: https://github.com/grpc/grpc-swift/issues/220
*/
#if !os(macOS)
dependencies.append(.package(url: "https://github.com/apple/swift-nio-zlib-support.git", from: "1.0.0"))
#endif

let package = Package(
name: "SwiftGRPC",
products: [
.library(name: "SwiftGRPC", targets: ["SwiftGRPC"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.0.2"),
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0"),
.package(url: "https://github.com/apple/swift-nio-zlib-support.git", from: "1.0.0")
],
dependencies: dependencies,
targets: [
.target(name: "SwiftGRPC",
dependencies: ["CgRPC", "SwiftProtobuf"]),
.target(name: "CgRPC",
dependencies: ["BoringSSL"]),
dependencies: cGRPCDependencies),
.target(name: "RootsEncoder"),
.target(name: "protoc-gen-swiftgrpc",
dependencies: [
Expand Down
50 changes: 50 additions & 0 deletions Sources/SwiftGRPC/Core/ChannelArgument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,38 @@ public extension Channel {
/// secure channel is an SSL channel). If this parameter is specified and the
/// underlying is not an SSL channel, it will just be ignored.
case sslTargetNameOverride(String)

/// Enable census for tracing and stats collection.
case enableCensus(Bool)

/// Enable load reporting.
case enableLoadReporting(Bool)

/// Request that optional features default to off (regarless of what they usually
/// default to) - to enable tight control over what gets enabled.
case enableMinimalStack(Bool)

/// Maximum number of concurrent incoming streams to allow on a http2 connection.
case maxConcurrentStreams(UInt)

/// Maximum message length that the channel can receive (in byts).
/// -1 means unlimited.
case maxReceiveMessageLength(Int)

/// Maximum message length that the channel can send (in bytes).
/// -1 means unlimited.
case maxSendMessageLength(Int)

/// Maximum time that a channel may have no outstanding rpcs.
case maxConnectionIdle(TimeInterval)

/// Maximum time that a channel may exist.
case maxConnectionAge(TimeInterval)

/// Enable/disable support for deadline checking.
/// Defaults to true, unless `enableMinimalStack` is enabled, in which case it
/// defaults to false.
case enableDeadlineChecks(Bool)
}
}

Expand Down Expand Up @@ -119,6 +151,24 @@ extension Channel.Argument {
return makeArgument("grpc.http2.max_pings_without_data", value: value)
case let .sslTargetNameOverride(value):
return makeArgument("grpc.ssl_target_name_override", value: value)
case let .enableCensus(value):
return makeArgument("grpc.census", value: value)
case let .enableLoadReporting(value):
return makeArgument("grpc.loadreporting", value: value)
case let .enableMinimalStack(value):
return makeArgument("grpc.minimal_stack", value: value)
case let .maxConcurrentStreams(value):
return makeArgument("grpc.max_concurrent_streams", value: value)
case let .maxReceiveMessageLength(value):
return makeArgument("grpc.max_receive_message_length", value: value)
case let .maxSendMessageLength(value):
return makeArgument("grpc.max_send_message_length", value: value)
case let .maxConnectionIdle(value):
return makeArgument("grpc.max_connection_idle_ms", value: value * 1_000)
case let .maxConnectionAge(value):
return makeArgument("grpc.max_connection_age_ms", value: value * 1_000)
case let .enableDeadlineChecks(value):
return makeArgument("grpc.enable_deadline_checking", value: value)
}
}
}
Expand Down

0 comments on commit e791f85

Please sign in to comment.