Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rnro committed Dec 24, 2024
1 parent 3ed26da commit 82764a9
Show file tree
Hide file tree
Showing 28 changed files with 1,437 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

plugin-tests:
name: Plugin tests
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Plugin tests"
matrix_linux_5_9_enabled: false
matrix_linux_5_10_enabled: false
matrix_linux_command: "./dev/plugin-tests.sh"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "1.28.2"
)
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2024, gRPC Authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import GRPCCore
import GRPCInProcessTransport
import GRPCProtobuf

@main
struct PluginAdopter {
static func main() async throws {
let inProcess = InProcessTransport()
try await withGRPCServer(transport: inProcess.server, services: [Greeter()]) { server in
try await withGRPCClient(transport: inProcess.client) { client in
try await Self.doRPC(Helloworld_Greeter.Client(wrapping: client))
}
}
}

static func doRPC(_ greeter: Helloworld_Greeter.Client) async throws {
do {
let reply = try await greeter.sayHello(.with { $0.name = "(ignored)" })
print("Reply: \(reply.message)")
} catch {
print("Error: \(error)")
}
}
}

struct Greeter: Helloworld_Greeter.SimpleServiceProtocol {
func sayHello(
request: Helloworld_HelloRequest,
context: ServerContext
) async throws -> Helloworld_HelloReply {
return .with { reply in
reply.message = "Hello, world!"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"protocPath": "/opt/homebrew/bin/protoc",
"visibility": "internal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "1.28.2"
)
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"protocPath": "/opt/homebrew/bin/protoc",
"visibility": "internal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2024, gRPC Authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import GRPCCore
import GRPCInProcessTransport
import GRPCProtobuf

@main
struct PluginAdopter {
static func main() async throws {
let inProcess = InProcessTransport()
try await withGRPCServer(transport: inProcess.server, services: [Greeter()]) { server in
try await withGRPCClient(transport: inProcess.client) { client in
try await Self.doRPC(Helloworld_Greeter.Client(wrapping: client))
}
}
}

static func doRPC(_ greeter: Helloworld_Greeter.Client) async throws {
do {
let reply = try await greeter.sayHello(.with { $0.name = "(ignored)" })
print("Reply: \(reply.message)")
} catch {
print("Error: \(error)")
}
}
}

struct Greeter: Helloworld_Greeter.SimpleServiceProtocol {
func sayHello(
request: Helloworld_HelloRequest,
context: ServerContext
) async throws -> Helloworld_HelloReply {
return .with { reply in
reply.message = "Hello, world!"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "1.28.2"
)
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}
Loading

0 comments on commit 82764a9

Please sign in to comment.