Skip to content

Commit

Permalink
Migrate RPC to ConnectRPC (#175)
Browse files Browse the repository at this point in the history
* Migrate RPC to ConnectRPC

* fix build settings

* Update Package.swift

* Update Sources/API/V1/run_protoc.sh

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
humdrum and coderabbitai[bot] authored May 28, 2024
1 parent ec867c8 commit d32e035
Show file tree
Hide file tree
Showing 38 changed files with 1,432 additions and 2,092 deletions.
69 changes: 21 additions & 48 deletions Examples/Example.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"pins" : [
{
"identity" : "grpc-swift",
"identity" : "connect-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"location" : "https://github.com/connectrpc/connect-swift",
"state" : {
"revision" : "d114c5ec34015bab663b3b7afaa7d6197656e47e",
"version" : "1.9.0"
"revision" : "15258d3ca83dc983ccb8f507c365b713672410c5",
"version" : "0.13.0"
}
},
{
Expand All @@ -23,37 +23,19 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036",
"version" : "1.0.3"
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "10bc670db657d11bdd561e07de30a9041311b2b1",
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
Expand All @@ -68,53 +50,44 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "e855380cb5234e96b760d93e0bfdc403e381e928",
"version" : "2.45.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "91dd2d61fb772e1311bb5f13b59266b579d77e42",
"version" : "1.15.0"
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
"version" : "2.65.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "d6656967f33ed8b368b38e4b198631fc7c484a40",
"version" : "1.23.1"
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "4fb7ead803e38949eb1d6fabb849206a72c580f3",
"version" : "2.23.0"
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "c0d9a144cfaec8d3d596aadde3039286a266c15c",
"version" : "1.15.0"
"revision" : "9f0c76544701845ad98716f3f6a774a892152bcb",
"version" : "1.26.0"
}
},
{
"identity" : "swift-protobuf",
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "e1499bc69b9040b29184f7f2996f7bab467c1639",
"version" : "1.19.0"
"revision" : "f9266c85189c2751589a50ea5aec72799797e471",
"version" : "1.3.0"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class KanbanViewModel: ObservableObject {
private let document: Document

init() {
self.client = Client(RPCAddress(host: "localhost", port: 8080))
self.client = Client("http://localhost:8080")

let docKey = "KanbanViewModel-8"
self.document = Document(key: docKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TextViewModel {
self.operationSubject = operationSubject

// create client with RPCAddress.
self.client = Client(RPCAddress(host: "localhost", port: 8080))
self.client = Client("http://localhost:8080")

// create a document
self.document = Document(key: "codemirror")
Expand Down
66 changes: 24 additions & 42 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"pins" : [
{
"identity" : "grpc-swift",
"identity" : "connect-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"location" : "https://github.com/connectrpc/connect-swift",
"state" : {
"revision" : "6bf35472cb8621481e59e6d1450b19627db81cea",
"version" : "1.13.1"
"revision" : "15258d3ca83dc983ccb8f507c365b713672410c5",
"version" : "0.13.0"
}
},
{
Expand All @@ -23,89 +23,71 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036",
"version" : "1.0.3"
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
"version" : "1.0.0"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
"version" : "1.4.4"
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "e855380cb5234e96b760d93e0bfdc403e381e928",
"version" : "2.45.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "91dd2d61fb772e1311bb5f13b59266b579d77e42",
"version" : "1.15.0"
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
"version" : "2.65.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "d6656967f33ed8b368b38e4b198631fc7c484a40",
"version" : "1.23.1"
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "4fb7ead803e38949eb1d6fabb849206a72c580f3",
"version" : "2.23.0"
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "c0d9a144cfaec8d3d596aadde3039286a266c15c",
"version" : "1.15.0"
"revision" : "9f0c76544701845ad98716f3f6a774a892152bcb",
"version" : "1.26.0"
}
},
{
"identity" : "swift-protobuf",
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "ab3a58b7209a17d781c0d1dbb3e1ff3da306bae8",
"version" : "1.20.3"
"revision" : "f9266c85189c2751589a50ea5aec72799797e471",
"version" : "1.3.0"
}
}
],
Expand Down
14 changes: 7 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ import PackageDescription

let package = Package(
name: "Yorkie",
platforms: [.iOS(.v13), .macOS(.v10_15)],
platforms: [.iOS(.v13), .macOS(.v13)],
products: [
.library(
name: "Yorkie",
targets: ["Yorkie"]
)
],
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.9.0"),
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.19.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/connectrpc/connect-swift", from: "0.13.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
.package(url: "https://github.com/groue/Semaphore.git", from: "0.0.8")
],
targets: [
.target(
name: "Yorkie",
dependencies: [.product(name: "GRPC", package: "grpc-swift"),
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
dependencies: [.product(name: "Connect", package: "connect-swift"),
.product(name: "Logging", package: "swift-log"),
.product(name: "Semaphore", package: "Semaphore")],
path: "Sources",
exclude: ["Info.plist",
"API/V1/yorkie/v1/resources.proto",
"API/V1/yorkie/v1/yorkie.proto"]
"API/V1/yorkie/v1/yorkie.proto",
"API/V1/buf.gen.yaml",
"API/V1/buf.yaml",
"API/V1/run_protoc.sh"]
),
.testTarget(
name: "YorkieUnitTests",
Expand Down
7 changes: 3 additions & 4 deletions Sources/API/GRPCTypeAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
// Use a Swift typealias to remap the type names of Protobuf locally
// Swift Protobuf Guide: https://github.com/apple/swift-protobuf/blob/main/Documentation/API.md#generated-struct-name
import Foundation
import Connect

typealias YorkieServiceNIOClient = Yorkie_V1_YorkieServiceNIOClient
typealias YorkieServiceAsyncClient = Yorkie_V1_YorkieServiceAsyncClient

typealias YorkieServiceClientInterceptorFactoryProtocol = Yorkie_V1_YorkieServiceClientInterceptorFactoryProtocol
typealias YorkieServiceClient = Yorkie_V1_YorkieServiceClient
typealias YorkieServerStream = Connect.ServerOnlyStreamInterface<WatchDocumentRequest>

typealias ActivateClientRequest = Yorkie_V1_ActivateClientRequest
typealias ActivateClientResponse = Yorkie_V1_ActivateClientResponse
Expand Down
Loading

0 comments on commit d32e035

Please sign in to comment.