Skip to content

Commit

Permalink
Merge pull request #2 from open-runtime/update-from-upstream
Browse files Browse the repository at this point in the history
Update from Upstream Master
  • Loading branch information
tsavo-at-pieces authored Jan 3, 2025
2 parents 774bf81 + c9d6286 commit 1dddfe0
Show file tree
Hide file tree
Showing 60 changed files with 755 additions and 473 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
sdk: [3.0.0, dev]
sdk: [3.5, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- name: Report version
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [3.0.0, dev]
sdk: [3.5, dev]
platform: [vm, chrome]
exclude:
# We only run Chrome tests on Linux. No need to run them
Expand All @@ -70,8 +70,8 @@ jobs:
- os: macos-latest
platform: chrome
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- name: Report version
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/health.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Health
on:
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened, labeled, unlabeled]
jobs:
health:
uses: dart-lang/ecosystem/.github/workflows/health.yaml@main
with:
checks: "changelog,do-not-submit,breaking,coverage,leaking"
ignore_coverage: "example/**,interop/**"
permissions:
pull-requests: write
17 changes: 17 additions & 0 deletions .github/workflows/post_summaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Comment on the pull request

on:
# Trigger this workflow after the Health workflow completes. This workflow will have permissions to
# do things like create comments on the PR, even if the original workflow couldn't.
workflow_run:
workflows:
- Health
- Publish
types:
- completed

jobs:
upload:
uses: dart-lang/ecosystem/.github/workflows/post_summaries.yaml@main
permissions:
pull-requests: write
27 changes: 24 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## 4.0.2-wip

* Internal optimization to client code.
* Small fixes, such as ports in testing and enabling `timeline_test.dart`.
* When the keep alive manager runs into a timeout, it will finish the transport instead of closing
the connection, as defined in the gRPC spec.
* Upgrade to `package:lints` version 5.0.0 and Dart SDK version 3.5.0.
* Upgrade `example/grpc-web` code.

## 4.0.1

* Fix header and trailing not completing if the call is terminated. Fixes [#727](https://github.com/grpc/grpc-dart/issues/727)

## 4.0.0

* Set compressed flag correctly for grpc-encoding = identity. Fixes [#669](https://github.com/grpc/grpc-dart/issues/669) (https://github.com/grpc/grpc-dart/pull/693)
* Remove generated status codes.
* Remove dependency on `package:archive`.
* Move `codec.dart`.
* Work around hang during Flutter hot restart by adding default case handler in _GrpcWebConversionSink.add.

## 3.2.4

* Forward internal `GrpcError` on when throwing while sending a request.
Expand All @@ -19,19 +40,19 @@

## 3.2.1

* `package:http` now supports more versions: `>=0.13.0 <2.0.0`.
* `package:http` now supports more versions: `>=0.13.0 <2.0.0`.
* `package:protobuf` new supports more versions: `>=2.0.0 <4.0.0`.

## 3.2.0

* `ChannelOptions` now exposes `connectTimeout`, which is used on the
* `ChannelOptions` now exposes `connectTimeout`, which is used on the
socket connect. This is used to specify the maximum allowed time to wait
for a connection to be established. If `connectTime` is longer than the system
level timeout duration, a timeout may occur sooner than specified in
`connectTimeout`. On timeout, a `SocketException` is thrown.
* Require Dart 2.17 or greater.
* Fix issue [#51](https://github.com/grpc/grpc-dart/issues/51), add support for custom error handling.
* Expose client IP address to server
* Expose client IP address to server
* Add a `channelShutdownHandler` argument to `ClientChannel` and the subclasses.
This callback can be used to react to channel shutdown or termination.
* Export the `Code` protobuf enum from the `grpc.dart` library.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
The [Dart](https://www.dart.dev/) implementation of
[gRPC](https://grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first.

[![CI status](https://github.com/grpc/grpc-dart/workflows/Dart/badge.svg)](https://github.com/grpc/grpc-dart/actions?query=workflow%3A%22Dart%22+branch%3Amaster)
[![Dart](https://github.com/grpc/grpc-dart/actions/workflows/dart.yml/badge.svg)](https://github.com/grpc/grpc-dart/actions/workflows/dart.yml)
[![pub package](https://img.shields.io/pub/v/grpc.svg)](https://pub.dev/packages/grpc)


## Learn more

- [Quick Start](https://grpc.io/docs/languages/dart/quickstart) - get an app running in minutes
- [Examples](example)
- [Examples](https://github.com/grpc/grpc-dart/tree/master/example)
- [API reference](https://grpc.io/docs/languages/dart/api)

For complete documentation, see [Dart gRPC](https://grpc.io/docs/languages/dart).
Expand Down
22 changes: 12 additions & 10 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ analyzer:

linter:
rules:
- always_declare_return_types
- cancel_subscriptions
- close_sinks
- directives_ordering
- omit_local_variable_types
- prefer_final_locals
- prefer_single_quotes
- test_types_in_equals
- use_super_parameters
- prefer_relative_imports
#true
always_declare_return_types: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
omit_local_variable_types: true
prefer_final_locals: true
prefer_single_quotes: true
test_types_in_equals: true
prefer_relative_imports: true
#false
unintended_html_in_doc_comment: false
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Four code examples are available:

1. [helloworld](https://github.com/grpc/grpc-dart/tree/master/example/helloworld):
A demonstration of using the Dart gRPC library to perform unary RPs.
A demonstration of using the Dart gRPC library to perform unary RPCs.

1. [googleapis](https://github.com/grpc/grpc-dart/tree/master/example/googleapis):
A demonstration of using the Dart gRPC library to communicate with Google APIs.
Expand Down
15 changes: 15 additions & 0 deletions example/grpc-web/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. 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 'dart:async';
import 'dart:html';

Expand Down
8 changes: 4 additions & 4 deletions example/grpc-web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ description: Dart gRPC-Web sample client
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ^3.5.0

dependencies:
grpc:
path: ../../
protobuf: ^3.0.0

dev_dependencies:
build_runner: ^2.0.0
build_web_compilers: '>3.0.0 <5.0.0'
lints: ^2.0.0
build_runner: ^2.4.13
build_web_compilers: ^4.0.11
lints: ^5.0.0
2 changes: 1 addition & 1 deletion example/helloworld/bin/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter client.
import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter client.
Future<void> main(List<String> args) async {
final channel = ClientChannel(
'localhost',
Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter server.
import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter server.
class GreeterService extends GreeterServiceBase {
@override
Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {
Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/unix_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter client.
import 'dart:io';

import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter client.
Future<void> main(List<String> args) async {
final udsAddress =
InternetAddress('localhost', type: InternetAddressType.unix);
Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/unix_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter server.
import 'dart:io';

import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter server.
class GreeterService extends GreeterServiceBase {
@override
Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {
Expand Down
4 changes: 2 additions & 2 deletions interop/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Tester {
final receivedBytes = response.payload.body.length;
if (receivedBytes != 314159) {
throw 'Response payload mismatch. Expected 314159 bytes, '
'got ${receivedBytes}.';
'got $receivedBytes.';
}
}

Expand Down Expand Up @@ -869,7 +869,7 @@ class Tester {
final receivedBytes = response.payload.body.length;
if (receivedBytes != 314159) {
throw 'Response payload mismatch. Expected 314159 bytes, '
'got ${receivedBytes}.';
'got $receivedBytes.';
}
return response;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/grpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// ignore: dangling_library_doc_comments
/// Status detail types and error codes
export 'package:grpc/src/generated/google/rpc/error_details.pb.dart';

export 'src/auth/auth.dart' show BaseAuthenticator;
export 'src/auth/auth_io.dart'
show
Expand All @@ -39,10 +43,6 @@ export 'src/client/options.dart'
export 'src/client/proxy.dart' show Proxy;
export 'src/client/transport/http2_credentials.dart'
show BadCertificateHandler, allowBadCertificates, ChannelCredentials;

/// Status detail types and error codes
export 'src/generated/google/rpc/code.pbenum.dart';
export 'src/generated/google/rpc/error_details.pb.dart';
export 'src/server/call.dart' show ServiceCall;
export 'src/server/interceptor.dart' show Interceptor;
export 'src/server/server.dart'
Expand Down
2 changes: 1 addition & 1 deletion lib/service_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/// Exports the minimum api to define server and client stubs.
///
/// Mainly intended to be imported by generated code.
library service_api;
library;

export 'src/client/call.dart' show CallOptions, MetadataProvider;
export 'src/client/channel.dart' show ClientChannel;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/auth/auth_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _CredentialsRefreshingAuthenticator extends HttpBasedAuthenticator {
await super.authenticate(metadata, uri);
if (_quotaProject != null) {
// https://cloud.google.com/apis/docs/system-parameters#definitions
metadata['X-Goog-User-Project'] = _quotaProject!;
metadata['X-Goog-User-Project'] = _quotaProject;
}
}

Expand Down
16 changes: 11 additions & 5 deletions lib/src/client/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class CallOptions {

CallOptions mergedWith(CallOptions? other) {
if (other == null) return this;
final mergedMetadata = Map.from(metadata)..addAll(other.metadata);
final mergedMetadata = Map.of(metadata)..addAll(other.metadata);
final mergedTimeout = other.timeout ?? timeout;
final mergedProviders = List.from(metadataProviders)
final mergedProviders = List.of(metadataProviders)
..addAll(other.metadataProviders);
final mergedCompression = other.compression ?? compression;
return CallOptions._(
Expand Down Expand Up @@ -146,9 +146,9 @@ class WebCallOptions extends CallOptions {
CallOptions mergedWith(CallOptions? other) {
if (other == null) return this;

final mergedMetadata = Map.from(metadata)..addAll(other.metadata);
final mergedMetadata = Map.of(metadata)..addAll(other.metadata);
final mergedTimeout = other.timeout ?? timeout;
final mergedProviders = List.from(metadataProviders)
final mergedProviders = List.of(metadataProviders)
..addAll(other.metadataProviders);

if (other is! WebCallOptions) {
Expand Down Expand Up @@ -241,7 +241,7 @@ class ClientCall<Q, R> implements Response {
if (options.metadataProviders.isEmpty) {
_sendRequest(connection, _sanitizeMetadata(options.metadata));
} else {
final metadata = Map<String, String>.from(options.metadata);
final metadata = Map<String, String>.of(options.metadata);
Future.forEach(
options.metadataProviders,
(MetadataProvider provider) => provider(metadata,
Expand Down Expand Up @@ -483,6 +483,12 @@ class ClientCall<Q, R> implements Response {
if (_responseSubscription != null) {
futures.add(_responseSubscription!.cancel());
}
if (!_headers.isCompleted) {
_headers.complete({});
}
if (!_trailers.isCompleted) {
_trailers.complete({});
}
await Future.wait(futures);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/http2_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Http2ClientConnection implements connection.ClientConnection {
transport.ping();
}
},
onPingTimeout: () => shutdown(),
onPingTimeout: () => transport.finish(),
);
transport.onFrameReceived
.listen((_) => keepAliveManager?.onFrameReceived());
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/transport/http2_credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ChannelCredentials {
if (!isSecure) return null;
if (_certificateBytes != null) {
return createSecurityContext(false)
..setTrustedCertificatesBytes(_certificateBytes!,
..setTrustedCertificatesBytes(_certificateBytes,
password: _certificatePassword);
}
final context = SecurityContext(withTrustedRoots: true);
Expand Down
Loading

0 comments on commit 1dddfe0

Please sign in to comment.