Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move v1 examples to v1 subdirectory #1963

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ extension Target {
.nio,
.protobuf,
],
path: "Sources/Examples/Echo/Model"
path: "Sources/Examples/v1/Echo/Model"
)

static let echoImplementation: Target = .target(
Expand All @@ -306,7 +306,7 @@ extension Target {
.nioHTTP2,
.protobuf,
],
path: "Sources/Examples/Echo/Implementation"
path: "Sources/Examples/v1/Echo/Implementation"
)

static let echo: Target = .executableTarget(
Expand All @@ -323,7 +323,7 @@ extension Target {
].appending(
.nioSSL, if: includeNIOSSL
),
path: "Sources/Examples/Echo/Runtime"
path: "Sources/Examples/v1/Echo/Runtime"
)

static let helloWorldModel: Target = .target(
Expand All @@ -333,7 +333,7 @@ extension Target {
.nio,
.protobuf,
],
path: "Sources/Examples/HelloWorld/Model"
path: "Sources/Examples/v1/HelloWorld/Model"
)

static let helloWorldClient: Target = .executableTarget(
Expand All @@ -345,7 +345,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/HelloWorld/Client"
path: "Sources/Examples/v1/HelloWorld/Client"
)

static let helloWorldServer: Target = .executableTarget(
Expand All @@ -357,7 +357,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/HelloWorld/Server"
path: "Sources/Examples/v1/HelloWorld/Server"
)

static let routeGuideModel: Target = .target(
Expand All @@ -367,7 +367,7 @@ extension Target {
.nio,
.protobuf,
],
path: "Sources/Examples/RouteGuide/Model"
path: "Sources/Examples/v1/RouteGuide/Model"
)

static let routeGuideClient: Target = .executableTarget(
Expand All @@ -379,7 +379,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/RouteGuide/Client"
path: "Sources/Examples/v1/RouteGuide/Client"
)

static let routeGuideServer: Target = .executableTarget(
Expand All @@ -392,7 +392,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/RouteGuide/Server"
path: "Sources/Examples/v1/RouteGuide/Server"
)

static let packetCapture: Target = .executableTarget(
Expand All @@ -405,7 +405,7 @@ extension Target {
.nioExtras,
.argumentParser,
],
path: "Sources/Examples/PacketCapture",
path: "Sources/Examples/v1/PacketCapture",
exclude: [
"README.md",
]
Expand Down Expand Up @@ -433,7 +433,7 @@ extension Target {
.echoModel,
.echoImplementation
],
path: "Sources/Examples/ReflectionService",
path: "Sources/Examples/v1/ReflectionService",
resources: [
.copy("Generated")
]
Expand Down
22 changes: 11 additions & 11 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ extension Target {
.nio,
.protobuf,
],
path: "Sources/Examples/Echo/Model",
path: "Sources/Examples/v1/Echo/Model",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -601,7 +601,7 @@ extension Target {
.nioHTTP2,
.protobuf,
],
path: "Sources/Examples/Echo/Implementation",
path: "Sources/Examples/v1/Echo/Implementation",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -621,7 +621,7 @@ extension Target {
].appending(
.nioSSL, if: includeNIOSSL
),
path: "Sources/Examples/Echo/Runtime",
path: "Sources/Examples/v1/Echo/Runtime",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -634,7 +634,7 @@ extension Target {
.nio,
.protobuf,
],
path: "Sources/Examples/HelloWorld/Model",
path: "Sources/Examples/v1/HelloWorld/Model",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -649,7 +649,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/HelloWorld/Client",
path: "Sources/Examples/v1/HelloWorld/Client",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -664,7 +664,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/HelloWorld/Server",
path: "Sources/Examples/v1/HelloWorld/Server",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -677,7 +677,7 @@ extension Target {
.nio,
.protobuf,
],
path: "Sources/Examples/RouteGuide/Model",
path: "Sources/Examples/v1/RouteGuide/Model",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -692,7 +692,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/RouteGuide/Client",
path: "Sources/Examples/v1/RouteGuide/Client",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -708,7 +708,7 @@ extension Target {
.nioPosix,
.argumentParser,
],
path: "Sources/Examples/RouteGuide/Server",
path: "Sources/Examples/v1/RouteGuide/Server",
swiftSettings: [.swiftLanguageVersion(.v5)]
)
}
Expand All @@ -724,7 +724,7 @@ extension Target {
.nioExtras,
.argumentParser,
],
path: "Sources/Examples/PacketCapture",
path: "Sources/Examples/v1/PacketCapture",
exclude: [
"README.md",
],
Expand Down Expand Up @@ -758,7 +758,7 @@ extension Target {
.echoModel,
.echoImplementation
],
path: "Sources/Examples/ReflectionService",
path: "Sources/Examples/v1/ReflectionService",
resources: [
.copy("Generated")
],
Expand Down
21 changes: 15 additions & 6 deletions Protos/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,33 @@ function invoke_protoc {

#------------------------------------------------------------------------------

function generate_echo_example {
function generate_echo_v1_example {
local proto="$here/examples/echo/echo.proto"
local output="$root/Sources/Examples/Echo/Model"
local output="$root/Sources/Examples/v1/Echo/Model"

generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Public"
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Public" "TestClient=true"
}

function generate_echo_v2_example {
local proto="$here/examples/echo/echo.proto"
local output="$root/Sources/Examples/v2/Echo/Generated"

generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal"
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal" "_V2=true"
}

function generate_routeguide_example {
local proto="$here/examples/route_guide/route_guide.proto"
local output="$root/Sources/Examples/RouteGuide/Model"
local output="$root/Sources/Examples/v1/RouteGuide/Model"

generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Public"
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Public"
}

function generate_helloworld_example {
local proto="$here/upstream/grpc/examples/helloworld.proto"
local output="$root/Sources/Examples/HelloWorld/Model"
local output="$root/Sources/Examples/v1/HelloWorld/Model"

generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Public"
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Public"
Expand Down Expand Up @@ -165,7 +173,7 @@ function generate_echo_reflection_data_for_tests {

function generate_reflection_data_example {
local protos=("$here/examples/echo/echo.proto" "$here/upstream/grpc/examples/helloworld.proto")
local output="$root/Sources/Examples/ReflectionService/Generated"
local output="$root/Sources/Examples/v1/ReflectionService/Generated"

for proto in "${protos[@]}"; do
generate_grpc "$proto" "$(dirname "$proto")" "$output" "Client=false" "Server=false" "ReflectionData=true"
Expand Down Expand Up @@ -243,7 +251,8 @@ function generate_health_service {
#------------------------------------------------------------------------------

# Examples
generate_echo_example
generate_echo_v1_example
generate_echo_v2_example
generate_routeguide_example
generate_helloworld_example
generate_reflection_data_example
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Sources/GRPCPerformanceTests/Benchmarks/echo.grpc.swift
2 changes: 1 addition & 1 deletion Sources/GRPCPerformanceTests/Benchmarks/echo.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This tutorial goes through the steps of adding Reflection service to a
server, running it and testing it using gRPCurl.

The server used in this example is implemented at
[Sources/Examples/ReflectionService/ReflectionServer.swift][reflection-server]
[Sources/Examples/v1/ReflectionService/ReflectionServer.swift][reflection-server]
and it supports the "Greeter", "Echo", and "Reflection" services.


Expand Down Expand Up @@ -38,27 +38,27 @@ describing the services of the server and the version of the reflection service.
The server from this example uses the `GreeterProvider` and the `EchoProvider`,
besides the `ReflectionService`.

The associated proto files are located at `Sources/Examples/HelloWorld/Model/helloworld.proto`, and
`Sources/Examples/Echo/Model/echo.proto` respectively.
The associated proto files are located at `Sources/Examples/v1/HelloWorld/Model/helloworld.proto`, and
`Sources/Examples/v1/Echo/Model/echo.proto` respectively.

In order to generate the reflection data for the `helloworld.proto`, you can run the following command:

```sh
$ protoc Sources/Examples/HelloWorld/Model/helloworld.proto \
--proto_path=Sources/Examples/HelloWorld/Model \
$ protoc Sources/Examples/v1/HelloWorld/Model/helloworld.proto \
--proto_path=Sources/Examples/v1/HelloWorld/Model \
--grpc-swift_opt=Client=false,Server=false,ReflectionData=true \
--grpc-swift_out=Sources/Examples/ReflectionService/Generated
--grpc-swift_out=Sources/Examples/v1/ReflectionService/Generated
```

Let's break the command down:
- The first argument passed to `protoc` is the path
to the `.proto` file to generate reflection data
for: [`Sources/Examples/HelloWorld/Model/helloworld.proto`][helloworld-proto].
- The `proto_path` flag is the path to search for imports: `Sources/Examples/HelloWorld/Model`.
for: [`Sources/Examples/v1/HelloWorld/Model/helloworld.proto`][helloworld-proto].
- The `proto_path` flag is the path to search for imports: `Sources/Examples/v1/HelloWorld/Model`.
- The 'grpc-swift_opt' flag allows us to list options for the Swift generator.
To generate only the reflection data set: `Client=false,Server=false,ReflectionData=true`.
- The `grpc-swift_out` flag is used to set the path of the directory
where the generated file will be located: `Sources/Examples/ReflectionService/Generated`.
where the generated file will be located: `Sources/Examples/v1/ReflectionService/Generated`.

This command assumes that the `protoc-gen-grpc-swift` plugin is in your `$PATH` environment variable.
You can learn how to get the plugin from this section of the `grpc-swift` README:
Expand Down Expand Up @@ -219,9 +219,9 @@ Note that when specifying a service, a method or a symbol, we have to use the fu
[grpc-cli]: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md
[v1]: ../v1/reflection-v1.proto
[v1alpha]: ../v1Alpha/reflection-v1alpha.proto
[reflection-server]: ../../Examples/ReflectionService/ReflectionServer.swift
[helloworld-proto]: ../../Examples/HelloWorld/Model/helloworld.proto
[echo-proto]: ../../Examples/Echo/Model/echo.proto
[reflection-server]: ../../Examples/v1/ReflectionService/ReflectionServer.swift
[helloworld-proto]: ../../Examples/v1/HelloWorld/Model/helloworld.proto
[echo-proto]: ../../Examples/v1/Echo/Model/echo.proto
[grpcurl-v188]: https://github.com/fullstorydev/grpcurl/releases/tag/v1.8.8
[swiftpm-resources]: https://github.com/apple/swift-package-manager/blob/main/Documentation/PackageDescription.md#resource
[spm-plugin]: ../../protoc-gen-grpc-swift/Docs.docc/spm-plugin.md
[spm-plugin]: ../../protoc-gen-grpc-swift/Docs.docc/spm-plugin.md
Loading
Loading