Skip to content

Commit 31933c8

Browse files
Add support for gRPC interface (#3)
* Adding grpc support * Add the QONECTIC gRPC client library * Track 0.9.0 line of Apodini Co-authored-by: Paul Schmiedmayer <[email protected]>
1 parent c1ef40d commit 31933c8

File tree

109 files changed

+11213
-1793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+11213
-1793
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
with:
2222
packagename: ApodiniMigratorExample
2323
test: false
24-
testdocc: false
2524
docker-compose-test:
2625
name: Docker Compose Test
2726
uses: Apodini/.github/.github/workflows/docker-compose-test.yml@v1

.github/workflows/pull_request.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
with:
2020
packagename: ApodiniMigratorExample
2121
test: false
22-
testdocc: false
2322
reuse_action:
2423
name: REUSE Compliance Check
2524
uses: Apodini/.github/.github/workflows/reuse.yml@v1

.swiftlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ only_rules:
325325
excluded: # paths to ignore during linting. Takes precedence over `included`.
326326
- .build
327327
- .swiftpm
328+
- ApodiniMigratorExampleClientGRPC
329+
- ApodiniMigratorExampleClientREST
328330

329331
closure_body_length: # Closure bodies should not span too many lines.
330332
- 35 # warning - default: 20

ApodiniMigratorExampleClientGRPC/Package.resolved

Lines changed: 196 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ApodiniMigratorExampleClientGRPC/Package.resolved.license

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// swift-tools-version:5.5
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
//
4+
// This source file is part of the Apodini open source project
5+
//
6+
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
7+
//
8+
// SPDX-License-Identifier: MIT
9+
//
10+
11+
import PackageDescription
12+
13+
let package = Package(
14+
name: "QONECTIQ",
15+
platforms: [
16+
.macOS(.v12), .iOS(.v15)
17+
],
18+
products: [
19+
.library(name: "QONECTIQ", targets: ["QONECTIQ"])
20+
],
21+
dependencies: [
22+
.package(url: "https://github.com/grpc/grpc-swift.git", .exact("1.6.0-async-await.1")),
23+
.package(url: "https://github.com/Apodini/ApodiniMigrator.git", .upToNextMinor(from: "0.3.0"))
24+
],
25+
targets: [
26+
.target(
27+
name: "QONECTIQ",
28+
dependencies: [
29+
.product(name: "GRPC", package: "grpc-swift"),.product(name: "ApodiniMigratorClientSupport", package: "ApodiniMigrator")
30+
],
31+
resources: [
32+
.process("Resources")
33+
]
34+
),
35+
.executableTarget(
36+
name: "QONECTIQClient",
37+
dependencies: [
38+
.target(name: "QONECTIQ")
39+
]
40+
)
41+
]
42+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
3+
This source file is part of the Apodini open source project
4+
5+
SPDX-FileCopyrightText: 2021 Paul Schmiedmayer and the project authors (see CONTRIBUTORS.md) <[email protected]>
6+
7+
SPDX-License-Identifier: MIT
8+
9+
-->
10+
11+
# QONECTIQ
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// This source file is part of the Apodini open source project
3+
//
4+
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
5+
//
6+
// SPDX-License-Identifier: MIT
7+
//
8+
9+
import NIO
10+
import NIOSSL
11+
import GRPC
12+
13+
open class GRPCNetworking {
14+
public static let verification: CertificateVerification = .none
15+
16+
public static let hostname = "127.0.0.1"
17+
public static let port = 8080
18+
19+
public let eventLoopGroup: EventLoopGroup
20+
21+
private var _defaultChannel: GRPCChannel?
22+
public var defaultChannel: GRPCChannel {
23+
get throws {
24+
guard let channel = _defaultChannel else {
25+
let channel = try GRPCChannelPool.with(
26+
target: .host(Self.hostname, port: Self.port),
27+
transportSecurity: .tls(.makeClientConfigurationBackedByNIOSSL(certificateVerification: Self.verification)),
28+
eventLoopGroup: eventLoopGroup
29+
)
30+
self._defaultChannel = channel
31+
return channel
32+
}
33+
34+
return channel
35+
}
36+
}
37+
38+
public init(eventLoopGroup: EventLoopGroup) {
39+
self.eventLoopGroup = eventLoopGroup
40+
}
41+
42+
public func close() -> EventLoopFuture<Void> {
43+
guard let channel = _defaultChannel else {
44+
return eventLoopGroup.next().makeSucceededVoidFuture()
45+
}
46+
47+
self._defaultChannel = nil
48+
return channel.close()
49+
}
50+
51+
deinit {
52+
try! close().wait()
53+
}
54+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// This source file is part of the Apodini open source project
3+
//
4+
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
5+
//
6+
// SPDX-License-Identifier: MIT
7+
//
8+
9+
import Foundation
10+
11+
public enum GRPCNetworkingError: Error {
12+
case streamingTypeMigrationError(type: StreamingTypeMigrationErrorType)
13+
}
14+
15+
/// Defines errors which might be thrown when a conversion from a
16+
/// service side stream to service side response fails.
17+
public enum StreamingTypeMigrationErrorType {
18+
/// Thrown if the first next() already fails to yield any response!
19+
case didNotReceiveAnyResponse
20+
}

0 commit comments

Comments
 (0)