Skip to content

Commit f420b77

Browse files
authored
Switch to Dart 3 (#633)
* Switch to Dart 3 * Trying to get the new version to run * Fix test * Switch CI to Dart 3 * Adapt CI * Do not run vmservice on chrome * Typo * Add skip to not fail on `dart test` * Add changelog entry * Changes as per review
1 parent 244dea0 commit f420b77

File tree

12 files changed

+39
-105
lines changed

12 files changed

+39
-105
lines changed

.github/workflows/dart.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
sdk: [dev, 2.17.0]
19+
sdk: [3.0.0, dev]
2020
steps:
2121
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
2222
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
@@ -60,7 +60,7 @@ jobs:
6060
strategy:
6161
matrix:
6262
os: [ubuntu-latest, macos-latest, windows-latest]
63-
sdk: [dev, 2.17.0]
63+
sdk: [3.0.0, dev]
6464
platform: [vm, chrome]
6565
exclude:
6666
# We only run Chrome tests on Linux. No need to run them
@@ -92,3 +92,6 @@ jobs:
9292
run: dart pub get
9393
- name: Run tests
9494
run: dart test --platform ${{ matrix.platform }}
95+
- name: Run vmservice test
96+
if: ${{ matrix.platform != 'chrome' }}
97+
run: dart run --enable-vm-service --timeline-streams=Dart test/timeline_test.dart

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Add a `channelShutdownHandler` argument to `ClientChannel` and the subclasses.
1212
This callback can be used to react to channel shutdown or termination.
1313
* Export the `Code` protobuf enum from the `grpc.dart` library.
14+
* Require Dart 3.0.0 or greater.
1415

1516
## 3.1.0
1617

lib/src/client/call.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,10 @@ class ClientCall<Q, R> implements Response {
369369
if (!_headers.isCompleted) {
370370
_headerMetadata = data.metadata;
371371
if (_requestTimeline != null) {
372-
_responseTimeline = timelineTaskFactory(
373-
parent: _requestTimeline, filterKey: clientTimelineFilterKey);
372+
_responseTimeline = TimelineTask(
373+
parent: _requestTimeline,
374+
filterKey: clientTimelineFilterKey,
375+
);
374376
}
375377
_responseTimeline?.start('gRPC Response');
376378
_responseTimeline?.instant('Metadata received', arguments: {

lib/src/client/channel.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// limitations under the License.
1515

1616
import 'dart:async';
17+
import 'dart:developer';
1718

1819
import '../shared/profiler.dart';
1920
import '../shared/status.dart';
@@ -109,7 +110,7 @@ abstract class ClientChannelBase implements ClientChannel {
109110
requests,
110111
options,
111112
isTimelineLoggingEnabled
112-
? timelineTaskFactory(filterKey: clientTimelineFilterKey)
113+
? TimelineTask(filterKey: clientTimelineFilterKey)
113114
: null);
114115
getConnection().then((connection) {
115116
if (call.isCancelled) return;

lib/src/client/common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ResponseStream<R> extends StreamView<R> with _ResponseMixin<dynamic, R> {
7676
ResponseFuture<R> get single => ResponseFuture(_call);
7777
}
7878

79-
abstract class _ResponseMixin<Q, R> implements Response {
79+
mixin _ResponseMixin<Q, R> implements Response {
8080
ClientCall<Q, R> get _call;
8181

8282
@override

lib/src/client/transport/web_streams.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GrpcWebDecoder extends Converter<ByteBuffer, GrpcMessage> {
3838
}
3939
}
4040

41-
class _GrpcWebConversionSink extends ChunkedConversionSink<ByteBuffer> {
41+
class _GrpcWebConversionSink implements ChunkedConversionSink<ByteBuffer> {
4242
static const int frameTypeData = 0x00;
4343
static const int frameTypeTrailers = 0x80;
4444

lib/src/shared/message.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GrpcData extends GrpcMessage {
4141
String toString() => 'gRPC Data (${data.length} bytes)';
4242
}
4343

44-
class GrpcMessageSink extends Sink<GrpcMessage> {
44+
class GrpcMessageSink implements Sink<GrpcMessage> {
4545
late final GrpcMessage message;
4646
bool _messageReceived = false;
4747

lib/src/shared/profiler.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
import 'dart:developer';
17-
18-
typedef TimelineTaskFactory = TimelineTask Function(
19-
{String? filterKey, TimelineTask? parent});
20-
21-
TimelineTaskFactory timelineTaskFactory = _defaultTimelineTaskFactory;
22-
23-
TimelineTask _defaultTimelineTaskFactory(
24-
{String? filterKey, TimelineTask? parent}) =>
25-
TimelineTask(filterKey: filterKey, parent: parent);
26-
2716
const String clientTimelineFilterKey = 'grpc/client';
2817

2918
/// Enable logging requests and response for clients.

lib/src/shared/streams.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class GrpcHttpDecoder extends Converter<StreamMessage, GrpcMessage> {
5959
}
6060
}
6161

62-
class _GrpcMessageConversionSink extends ChunkedConversionSink<StreamMessage> {
62+
class _GrpcMessageConversionSink
63+
implements ChunkedConversionSink<StreamMessage> {
6364
final Sink<GrpcMessage> _out;
6465
final bool _forResponse;
6566

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version: 3.2.0-dev
66
repository: https://github.com/grpc/grpc-dart
77

88
environment:
9-
sdk: '>=2.17.0 <3.0.0'
9+
sdk: '>=3.0.0 <4.0.0'
1010

1111
dependencies:
1212
archive: ^3.0.0
@@ -28,6 +28,7 @@ dev_dependencies:
2828
test: ^1.16.0
2929
stream_channel: ^2.1.0
3030
stream_transform: ^2.0.0
31+
vm_service: ^11.6.0
3132

3233
false_secrets:
3334
- interop/server1.key

0 commit comments

Comments
 (0)