Skip to content

Commit

Permalink
Add support for gRPC interface (#3)
Browse files Browse the repository at this point in the history
* Adding grpc support

* Add the QONECTIC gRPC client library

* Track 0.9.0 line of Apodini

Co-authored-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
Supereg and PSchmiedmayer authored Apr 13, 2022
1 parent c1ef40d commit 31933c8
Show file tree
Hide file tree
Showing 109 changed files with 11,213 additions and 1,793 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
with:
packagename: ApodiniMigratorExample
test: false
testdocc: false
docker-compose-test:
name: Docker Compose Test
uses: Apodini/.github/.github/workflows/docker-compose-test.yml@v1
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
with:
packagename: ApodiniMigratorExample
test: false
testdocc: false
reuse_action:
name: REUSE Compliance Check
uses: Apodini/.github/.github/workflows/reuse.yml@v1
Expand Down
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ only_rules:
excluded: # paths to ignore during linting. Takes precedence over `included`.
- .build
- .swiftpm
- ApodiniMigratorExampleClientGRPC
- ApodiniMigratorExampleClientREST

closure_body_length: # Closure bodies should not span too many lines.
- 35 # warning - default: 20
Expand Down
196 changes: 196 additions & 0 deletions ApodiniMigratorExampleClientGRPC/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"object": {
"pins": [
{
"package": "ApodiniDocumentExport",
"repositoryURL": "https://github.com/Apodini/ApodiniDocumentExport.git",
"state": {
"branch": null,
"revision": "0a3fe4195f011057ad2cd5150c9091f2a17c2ec1",
"version": "0.1.1"
}
},
{
"package": "ApodiniMigrator",
"repositoryURL": "https://github.com/Apodini/ApodiniMigrator.git",
"state": {
"branch": null,
"revision": "10671191ddd8a19a61ac6cae06060d259dbfe9ce",
"version": "0.3.0"
}
},
{
"package": "ApodiniTypeInformation",
"repositoryURL": "https://github.com/Apodini/ApodiniTypeInformation.git",
"state": {
"branch": null,
"revision": "40247bedd5153b7641e95a11bd826b16a15fd12e",
"version": "0.3.6"
}
},
{
"package": "AssociatedTypeRequirementsKit",
"repositoryURL": "https://github.com/nerdsupremacist/AssociatedTypeRequirementsKit.git",
"state": {
"branch": null,
"revision": "2e4c49c21ffb2135f1c99fbfcf2119c9d24f5e8c",
"version": "0.3.2"
}
},
{
"package": "FineJSON",
"repositoryURL": "https://github.com/omochi/FineJSON.git",
"state": {
"branch": null,
"revision": "05101709243cb66d80c92e645210a3b80cf4e17f",
"version": "1.14.0"
}
},
{
"package": "grpc-swift",
"repositoryURL": "https://github.com/grpc/grpc-swift.git",
"state": {
"branch": null,
"revision": "0dd42b5b1bafc56548bdbf3a0ba06898944dc4ba",
"version": "1.6.0-async-await.1"
}
},
{
"package": "MetadataSystem",
"repositoryURL": "https://github.com/Apodini/MetadataSystem.git",
"state": {
"branch": null,
"revision": "f655813f1953af8d3aaac432dad35f394e7bdf75",
"version": "0.1.6"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version": "1.0.1"
}
},
{
"package": "RichJSONParser",
"repositoryURL": "https://github.com/omochi/RichJSONParser.git",
"state": {
"branch": null,
"revision": "263e2ecfe88d0500fa99e4cbc8c948529d335534",
"version": "3.0.0"
}
},
{
"package": "Runtime",
"repositoryURL": "https://github.com/wickwirew/Runtime.git",
"state": {
"branch": null,
"revision": "dad03135d7701a4e7b3a4051e75d6b37bd8e178e",
"version": "2.2.4"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version": "0.10.1"
}
},
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "83b23d940471b313427da226196661856f6ba3e0",
"version": "0.4.4"
}
},
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections.git",
"state": {
"branch": null,
"revision": "48254824bb4248676bf7ce56014ff57b142b77eb",
"version": "1.0.2"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version": "1.4.2"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "51c3fc2e4a0fcdf4a25089b288dd65b73df1b0ef",
"version": "2.37.0"
}
},
{
"package": "swift-nio-extras",
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
"state": {
"branch": null,
"revision": "f73ca5ee9c6806800243f1ac415fcf82de9a4c91",
"version": "1.10.2"
}
},
{
"package": "swift-nio-http2",
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
"state": {
"branch": null,
"revision": "6e94a7be32891d1b303a3fcfde8b5bf64d162e74",
"version": "1.19.1"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "52a486ff6de9bc3e26bf634c5413c41c5fa89ca5",
"version": "2.17.2"
}
},
{
"package": "swift-nio-transport-services",
"repositoryURL": "https://github.com/apple/swift-nio-transport-services.git",
"state": {
"branch": null,
"revision": "8ab824b140d0ebcd87e9149266ddc353e3705a3e",
"version": "1.11.4"
}
},
{
"package": "SwiftProtobuf",
"repositoryURL": "https://github.com/apple/swift-protobuf.git",
"state": {
"branch": null,
"revision": "7e2c5f3cbbeea68e004915e3a8961e20bd11d824",
"version": "1.18.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version": "4.0.6"
}
}
]
},
"version": 1
}
7 changes: 7 additions & 0 deletions ApodiniMigratorExampleClientGRPC/Package.resolved.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// This source file is part of the Apodini open source project
//
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
//
// SPDX-License-Identifier: MIT
//
42 changes: 42 additions & 0 deletions ApodiniMigratorExampleClientGRPC/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
//
// This source file is part of the Apodini open source project
//
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
//
// SPDX-License-Identifier: MIT
//

import PackageDescription

let package = Package(
name: "QONECTIQ",
platforms: [
.macOS(.v12), .iOS(.v15)
],
products: [
.library(name: "QONECTIQ", targets: ["QONECTIQ"])
],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", .exact("1.6.0-async-await.1")),
.package(url: "https://github.com/Apodini/ApodiniMigrator.git", .upToNextMinor(from: "0.3.0"))
],
targets: [
.target(
name: "QONECTIQ",
dependencies: [
.product(name: "GRPC", package: "grpc-swift"),.product(name: "ApodiniMigratorClientSupport", package: "ApodiniMigrator")
],
resources: [
.process("Resources")
]
),
.executableTarget(
name: "QONECTIQClient",
dependencies: [
.target(name: "QONECTIQ")
]
)
]
)
11 changes: 11 additions & 0 deletions ApodiniMigratorExampleClientGRPC/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
This source file is part of the Apodini open source project
SPDX-FileCopyrightText: 2021 Paul Schmiedmayer and the project authors (see CONTRIBUTORS.md) <[email protected]>
SPDX-License-Identifier: MIT
-->

# QONECTIQ
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// This source file is part of the Apodini open source project
//
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
//
// SPDX-License-Identifier: MIT
//

import NIO
import NIOSSL
import GRPC

open class GRPCNetworking {
public static let verification: CertificateVerification = .none

public static let hostname = "127.0.0.1"
public static let port = 8080

public let eventLoopGroup: EventLoopGroup

private var _defaultChannel: GRPCChannel?
public var defaultChannel: GRPCChannel {
get throws {
guard let channel = _defaultChannel else {
let channel = try GRPCChannelPool.with(
target: .host(Self.hostname, port: Self.port),
transportSecurity: .tls(.makeClientConfigurationBackedByNIOSSL(certificateVerification: Self.verification)),
eventLoopGroup: eventLoopGroup
)
self._defaultChannel = channel
return channel
}

return channel
}
}

public init(eventLoopGroup: EventLoopGroup) {
self.eventLoopGroup = eventLoopGroup
}

public func close() -> EventLoopFuture<Void> {
guard let channel = _defaultChannel else {
return eventLoopGroup.next().makeSucceededVoidFuture()
}

self._defaultChannel = nil
return channel.close()
}

deinit {
try! close().wait()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// This source file is part of the Apodini open source project
//
// SPDX-FileCopyrightText: 2019-2022 Paul Schmiedmayer and the Apodini project authors (see CONTRIBUTORS.md) <[email protected]>
//
// SPDX-License-Identifier: MIT
//

import Foundation

public enum GRPCNetworkingError: Error {
case streamingTypeMigrationError(type: StreamingTypeMigrationErrorType)
}

/// Defines errors which might be thrown when a conversion from a
/// service side stream to service side response fails.
public enum StreamingTypeMigrationErrorType {
/// Thrown if the first next() already fails to yield any response!
case didNotReceiveAnyResponse
}
Loading

0 comments on commit 31933c8

Please sign in to comment.