Skip to content

Commit e8e48f2

Browse files
committed
Address feedback from gus
1 parent 2327329 commit e8e48f2

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ from 1.x to 2.x. You'll use the following strategy:
1212

1313
1. Setup your package so it depends on a local copy of gRPC Swift 1.x and the
1414
upstream version of 2.x.
15-
2. Generate code for 2.x to alongside generated 1.x code.
15+
2. Generate code for 2.x alongside generated 1.x code.
1616
3. Incrementally migrate targets to 2.x.
17-
4. Remove the code generated for, and the dependency on 1.x.
17+
4. Remove the code generated for, and the dependency on, 1.x.
1818

1919
You'll do this migration incrementally by staging in a local copy of gRPC Swift
2020
1.x and migrating client and service code on a per service basis. This approach
@@ -284,7 +284,7 @@ Repeat this until you've done all services in your package.
284284
If you're reading this section then you're likely relying on metadata in your
285285
service. This means you need to implement the `ServiceProtocol` instead of the
286286
`SimpleServiceProtocol` and the transformations you need to apply are
287-
aren't well suited automation. The best approach is to conform your
287+
aren't well suited for automation. The best approach is to conform your
288288
service to the 1.x protocol and the 2.x protocol. Add conformance to the
289289
`{Service}.ServiceProtocol` where `{Service}` is the namespaced name of your
290290
service (if your service is called `Baz` and declared in the `foo.bar` Protocol
@@ -297,7 +297,9 @@ and return a `ServerResponse` or `StreamingServerResponse`. Request metadata is
297297
available on the request object. For single responses you can set initial and
298298
trailing metadata when you create the response. For streaming responses you can
299299
set initial metadata in the initializer and return trailing metadata from the
300-
closure you provide to the initializer.
300+
closure you provide to the initializer. This is demonstrated in the
301+
['echo-metadata'](https://github.com/grpc/grpc-swift/tree/main/Examples/echo-metadata)
302+
example.
301303

302304
One important difference between this approach and the `SimpleServiceProtocol`
303305
(and 1.x) is that responses aren't completed until the body of the response has
@@ -384,19 +386,14 @@ Change the body of the function using the 1.x client to just `fatalError()`.
384386
Later you'll remove this function altogether.
385387

386388
If the generated client is a stored type then add a new computed property
387-
returning an instance of it, the body can just call `fatalError()` for now:
389+
returning an instance of it. the body can just call `fatalError()` for now:
388390

389391
```swift
390392
var client: Foo_Bar_Baz.Client {
391393
fatalError("TODO")
392394
}
393395
```
394396

395-
If a generated client is passed into the function then duplicate the function
396-
and replace the body of the new version with a `fatalError()`. You can also mark
397-
it as deprecated to help you find usages of the function. You'll now have two
398-
versions of the same function.
399-
400397
Now you need to update the function to use the new client. For unary calls the API
401398
is very similar, so you may not have to change any code. An important change to
402399
highlight is that for RPCs which stream their responses you must handle the

dev/v1-to-v2/v1_to_v2.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,20 @@ function checkout_v1 {
2727
grpc_checkout_dir="$(realpath "$1")"
2828
# The path of the checkout.
2929
grpc_checkout_path="${grpc_checkout_dir}/grpc-swift-v1"
30-
# Version of grpc-swift to checkout.
31-
grpc_v1_tag="1.24.2"
3230

3331
# Clone the repo.
34-
log "Cloning v${grpc_v1_tag} to ${grpc_checkout_path}"
32+
log "Cloning grpc-swift to ${grpc_checkout_path}"
3533
git clone \
36-
--depth 1 \
37-
--branch "$grpc_v1_tag" \
34+
--quiet \
3835
https://github.com/grpc/grpc-swift.git \
3936
"${grpc_checkout_path}"
4037

38+
# Get the latest version of 1.x.y.
39+
local -r version=$(git -C "${grpc_checkout_path}" tag --list | grep '1.\([0-9]\+\).\([0-9]\+\)$' | sort -V | tail -n 1)
40+
41+
log "Checking out $version"
42+
git -C "${grpc_checkout_path}" checkout --quiet "$version"
43+
4144
# Remove the git bits.
4245
log "Removing ${grpc_checkout_path}/.git"
4346
rm -rf "${grpc_checkout_path}/.git"
@@ -61,7 +64,7 @@ function checkout_v1 {
6164
-exec sed -i '' 's/protoc-gen-grpc-swift/protoc-gen-grpc-swift-v1/g' {} +
6265

6366
# Update the path of the protoc plugin so it aligns with the target name.
64-
log "Updating direcotry name for protoc-gen-grpc-swift-v1"
67+
log "Updating directory name for protoc-gen-grpc-swift-v1"
6568
mv "${grpc_checkout_path}/Sources/protoc-gen-grpc-swift" "${grpc_checkout_path}/Sources/protoc-gen-grpc-swift-v1"
6669

6770
log "Cloned and patched v1 to: ${grpc_checkout_path}"

0 commit comments

Comments
 (0)