Skip to content

update deps to latest #1498

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ common --incompatible_allow_tags_propagation
# Fail if a glob doesn't match anything (https://github.com/bazelbuild/bazel/issues/8195)
build --incompatible_disallow_empty_glob

build --host_macos_minimum_os=13.0
build --macos_minimum_os=13.0
build --host_macos_minimum_os=15.0
build --macos_minimum_os=15.0

# We don't need to bump some of our dependencies, just becuse our dev
# dependencies cause us to use a newer version
Expand Down
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ use_repo(
"com_github_apple_swift_nio_transport_services",
"com_github_apple_swift_protobuf",
"com_github_grpc_grpc_swift",
"com_github_grpc_grpc_swift_protobuf",
"com_github_grpc_grpc_swift_nio_transport",
)

apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension")
Expand Down
12 changes: 0 additions & 12 deletions doc/proto_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,6 @@ swift_proto_library(
],
protos = [":service_proto"],
)

swift_proto_library(
name = "service_test_client_swift_proto",
additional_compiler_info = {
"ExtraModuleImports": "examples_xplatform_grpc_service_client_swift_proto",
},
compiler_deps = [
":service_client_swift_proto",
],
compilers = ["@build_bazel_rules_swift//proto/compilers:swift_test_client_proto"],
protos = [":service_proto"],
)
```

Note here that we don't need the intermediate `swift_proto_library` target,
Expand Down
18 changes: 7 additions & 11 deletions examples/xplatform/grpc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ swift_binary(
srcs = ["server_main.swift"],
deps = [
"//examples/xplatform/grpc/service:service_server_swift_proto",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOCore",
],
)

Expand All @@ -28,6 +30,9 @@ swift_binary(
srcs = ["client_main.swift"],
deps = [
"//examples/xplatform/grpc/service:service_client_swift_proto",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOCore",
"@com_github_grpc_grpc_swift_nio_transport//:GRPCNIOTransportHTTP2",
],
)

Expand All @@ -39,16 +44,7 @@ swift_test(
deps = [
"//examples/xplatform/grpc/service:service_client_swift_proto",
"//examples/xplatform/grpc/service:service_server_swift_proto",
],
)

swift_test(
name = "echo_test_client_unit_test",
srcs = [
"test_client_unit_test.swift",
],
deps = [
"//examples/xplatform/grpc/service:service_client_swift_proto",
"//examples/xplatform/grpc/service:service_test_client_swift_proto",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOCore",
],
)
62 changes: 27 additions & 35 deletions examples/xplatform/grpc/client_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,41 @@

import Foundation
import SwiftProtobuf
import GRPC
import GRPCCore
import NIOCore
import NIOPosix
import ServiceClient
import GRPCNIOTransportHTTP2

@main
struct ClientMain {
@MainActor
static func main() throws {
// Setup an `EventLoopGroup` for the connection to run on.
//
// See: https://github.com/apple/swift-nio#eventloops-and-eventloopgroups
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)

// Make sure the group is shutdown when we're done with it.
defer {
try! group.syncShutdownGracefully()
}

// Configure the channel, we're not using TLS so the connection is `insecure`.
let channel = try GRPCChannelPool.with(
target: .host("localhost", port: 9000),
transportSecurity: .plaintext,
eventLoopGroup: group
)

// Initialize the client using the same address the server is started on.
let client = Service_EchoServiceNIOClient(channel: channel)

// Construct a request to the echo service.
let request = Service_EchoRequest.with {
$0.contents = "Hello, world!"
let timestamp = Google_Protobuf_Timestamp(date: Date())
$0.extra = try! Google_Protobuf_Any(message: timestamp)
}

let call = client.echo(request)

// Make the remote method call and print the response we receive.
do {
let response = try call.response.wait()
print(response.contents)
} catch {
print("Echo failed: \(error)")
try await withGRPCClient(
transport: .http2NIOPosix(
target: .host("localhost", port: 9000),
transportSecurity: .plaintext
)
) { client in
let echo = Service_EchoService.Client(wrapping: client)

// Construct a request to the echo service.
let request = Service_EchoRequest.with {
$0.contents = "Hello, world!"
let timestamp = Google_Protobuf_Timestamp(date: Date())
$0.extra = try! Google_Protobuf_Any(message: timestamp)
}

let call = client.echo(request)

// Make the remote method call and print the response we receive.
do {
let response = try await call.response
print(response.contents)
} catch {
print("Echo failed: \(error)")
}
}
}
}
4 changes: 2 additions & 2 deletions examples/xplatform/grpc/client_unit_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

import ServiceClient
import ServiceServer
import GRPC
import GRPCCore
import NIOCore
import NIOPosix
import XCTest

public class EchoServiceProvider: Service_EchoServiceProvider {
public class EchoServiceProvider: Service_EchoService.ClientProtocol {
public let interceptors: Service_EchoServiceServerInterceptorFactoryProtocol?

public init(interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? = nil) {
Expand Down
4 changes: 2 additions & 2 deletions examples/xplatform/grpc/server_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
// limitations under the License.

import Dispatch
import GRPC
import GRPCCore
import NIOCore
import NIOPosix
import ServiceServer

/// Concrete implementation of the `EchoService` service definition.
class EchoProvider: Service_EchoServiceProvider {
class EchoProvider: Service_EchoService.ClientProtocol {
var interceptors: Service_EchoServiceServerInterceptorFactoryProtocol?

/// Called when the server receives a request for the `EchoService.Echo` method.
Expand Down
16 changes: 0 additions & 16 deletions examples/xplatform/grpc/service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,3 @@ swift_proto_library(
protos = [":service_proto"],
visibility = ["//visibility:public"],
)

swift_proto_library(
name = "service_test_client_swift_proto",
additional_compiler_deps = [
"//examples/xplatform/grpc/service:service_client_swift_proto",
],
additional_compiler_info = {
"ExtraModuleImports": "ServiceClient",
},
compilers = [
"//proto/compilers:swift_test_client_proto",
],
module_name = "ServiceTestClient",
protos = [":service_proto"],
visibility = ["//visibility:public"],
)
50 changes: 0 additions & 50 deletions examples/xplatform/grpc/test_client_unit_test.swift

This file was deleted.

6 changes: 6 additions & 0 deletions examples/xplatform/proto_library_group/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ swift_binary(
srcs = ["server_main.swift"],
deps = [
"//examples/xplatform/proto_library_group/service:service_server_swift_proto",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOCore",
],
)

Expand All @@ -14,6 +16,8 @@ swift_binary(
srcs = ["client_main.swift"],
deps = [
"//examples/xplatform/proto_library_group/service:service_client_swift_proto",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOCore",
],
)

Expand All @@ -25,5 +29,7 @@ swift_test(
deps = [
"//examples/xplatform/proto_library_group/service:service_client_swift_proto",
"//examples/xplatform/proto_library_group/service:service_server_swift_proto",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOCore",
],
)
2 changes: 1 addition & 1 deletion examples/xplatform/proto_library_group/client_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Foundation
import SwiftProtobuf
import GRPC
import GRPCCore
import NIOCore
import NIOPosix
import examples_xplatform_proto_library_group_request_request_proto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import GRPC
import GRPCCore
import NIOCore
import NIOPosix
import XCTest
Expand All @@ -21,7 +21,7 @@ import examples_xplatform_proto_library_group_response_response_proto
import ServiceClient
import ServiceServer

public class EchoServiceProvider: Service_EchoServiceProvider {
public class EchoServiceProvider: Service_EchoService.ClientProtocol {
public let interceptors: Service_EchoServiceServerInterceptorFactoryProtocol?

public init(interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? = nil) {
Expand Down
4 changes: 2 additions & 2 deletions examples/xplatform/proto_library_group/server_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
// limitations under the License.

import Dispatch
import GRPC
import GRPCCore
import NIOCore
import NIOPosix
import examples_xplatform_proto_library_group_request_request_proto
import examples_xplatform_proto_library_group_response_response_proto
import ServiceServer

/// Concrete implementation of the `EchoService` service definition.
class EchoProvider: Service_EchoServiceProvider {
class EchoProvider: Service_EchoService.ClientProtocol {
var interceptors: Service_EchoServiceServerInterceptorFactoryProtocol?

/// Called when the server receives a request for the `EchoService.Echo` method.
Expand Down
6 changes: 0 additions & 6 deletions proto/compilers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load(
"//proto/compilers:swift_proto_compiler_macros.bzl",
"GRPC_VARIANT_CLIENT",
"GRPC_VARIANT_SERVER",
"GRPC_VARIANT_TEST_CLIENT",
"PROTO_PLUGIN_OPTIONS",
"PROTO_PLUGIN_OPTION_ALLOWLIST",
"make_grpc_swift_proto_compiler",
Expand Down Expand Up @@ -40,11 +39,6 @@ make_grpc_swift_proto_compiler(
variants = [GRPC_VARIANT_CLIENT],
)

make_grpc_swift_proto_compiler(
name = "swift_test_client_proto",
variants = [GRPC_VARIANT_TEST_CLIENT],
)

bzl_library(
name = "swift_proto_compiler_macros",
srcs = ["swift_proto_compiler_macros.bzl"],
Expand Down
6 changes: 2 additions & 4 deletions proto/compilers/swift_proto_compiler_macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ PROTO_PLUGIN_OPTIONS = {
}
GRPC_VARIANT_SERVER = "Server"
GRPC_VARIANT_CLIENT = "Client"
GRPC_VARIANT_TEST_CLIENT = "TestClient"
GRPC_VARIANTS = [
GRPC_VARIANT_SERVER,
GRPC_VARIANT_CLIENT,
GRPC_VARIANT_TEST_CLIENT,
]
GRPC_PLUGIN_OPTION_ALLOWLIST = PROTO_PLUGIN_OPTION_ALLOWLIST + [
"KeepMethodCasing",
Expand Down Expand Up @@ -76,8 +74,8 @@ def make_grpc_swift_proto_compiler(
plugin_options = merged_plugin_options,
suffixes = [".grpc.swift"],
deps = [
"@com_github_apple_swift_protobuf//:SwiftProtobuf",
"@com_github_grpc_grpc_swift//:GRPC",
"@com_github_grpc_grpc_swift_protobuf//:GRPCProtobuf",
"@com_github_grpc_grpc_swift//:GRPCCore",
],
visibility = ["//visibility:public"],
)
Loading