Skip to content

update deps; simplify analysis options #790

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
sdk: [3.5, dev]
sdk: [stable, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: dart pub get
- name: Check formatting (using dev dartfmt release)
if: ${{ matrix.sdk == 'dev' }}
if: ${{ matrix.sdk == 'stable' }}
run: dart format --output=none --set-exit-if-changed .
- name: Analyze code (introp and examples)
run: |
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [3.5, dev]
sdk: [stable, dev]
platform: [vm, chrome]
exclude:
# We only run Chrome tests on Linux. No need to run them
Expand Down
18 changes: 14 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
## 4.1.1-wip

- Require Dart 3.8.
- Dart format all files for the new 3.8 formatter.
- Require package:googleapis_auth
- Require package:http 1.4.0
- Require package:lints 6.0.0
- Require package:protobuf 4.1.0

## 4.1.0
* Add a `serverInterceptors` argument to `ConnectionServer`. These interceptors are acting
as middleware, wrapping a `ServiceMethod` invocation.

* Add a `serverInterceptors` argument to `ConnectionServer`. These interceptors
are acting as middleware, wrapping a `ServiceMethod` invocation.
* Make sure that `CallOptions.mergeWith` is symmetric: given `WebCallOptions`
it should return `WebCallOptions`.

Expand All @@ -16,8 +26,8 @@

* 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.
* 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.
* Update xhr transport to migrate off legacy JS/HTML apis.
Expand Down
3 changes: 1 addition & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ linter:
- prefer_final_locals
- prefer_relative_imports
- prefer_single_quotes
# Enable once 3.7 is stable.
# - strict_top_level_inference
- strict_top_level_inference
- test_types_in_equals
4 changes: 0 additions & 4 deletions example/googleapis/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include: ../../analysis_options.yaml

linter:
rules:
directives_ordering: false
31 changes: 19 additions & 12 deletions example/googleapis/bin/logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@
import 'dart:async';
import 'dart:io';

import 'package:grpc/grpc.dart';

import 'package:googleapis/src/generated/google/api/monitored_resource.pb.dart';
import 'package:googleapis/src/generated/google/logging/type/log_severity.pb.dart';
import 'package:googleapis/src/generated/google/logging/v2/log_entry.pb.dart';
import 'package:googleapis/src/generated/google/logging/v2/logging.pbgrpc.dart';
import 'package:grpc/grpc.dart';

Future<void> main() async {
final serviceAccountFile = File('logging-service-account.json');
if (!serviceAccountFile.existsSync()) {
print('File logging-service-account.json not found. Please follow the '
'steps in README.md to create it.');
print(
'File logging-service-account.json not found. Please follow the '
'steps in README.md to create it.',
);
exit(-1);
}

Expand All @@ -37,19 +38,25 @@ Future<void> main() async {
];

final authenticator = ServiceAccountAuthenticator(
serviceAccountFile.readAsStringSync(), scopes);
serviceAccountFile.readAsStringSync(),
scopes,
);
final projectId = authenticator.projectId;

final channel = ClientChannel('logging.googleapis.com');
final logging =
LoggingServiceV2Client(channel, options: authenticator.toCallOptions);
final logging = LoggingServiceV2Client(
channel,
options: authenticator.toCallOptions,
);

final request = WriteLogEntriesRequest()
..entries.add(LogEntry()
..logName = 'projects/$projectId/logs/example'
..severity = LogSeverity.INFO
..resource = (MonitoredResource()..type = 'global')
..textPayload = 'This is a log entry!');
..entries.add(
LogEntry()
..logName = 'projects/$projectId/logs/example'
..severity = LogSeverity.INFO
..resource = (MonitoredResource()..type = 'global')
..textPayload = 'This is a log entry!',
);
await logging.writeLogEntries(request);

await channel.shutdown();
Expand Down
12 changes: 6 additions & 6 deletions example/googleapis/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ description: Dart gRPC client sample for Google APIs
publish_to: none

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ^3.8.0

dependencies:
async: ^2.2.0
fixnum:
async: ^2.13.0
fixnum: ^1.1.1
grpc:
path: ../../
protobuf: ">=3.0.0 <5.0.0"
protobuf: ^4.1.0

dev_dependencies:
lints: ^2.0.0
test: ^1.6.4
lints: ^6.0.0
test: ^1.26.2
6 changes: 1 addition & 5 deletions example/grpc-web/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include: ../../analysis_options.yaml

linter:
rules:
directives_ordering: false
include: package:lints/recommended.yaml
37 changes: 25 additions & 12 deletions example/grpc-web/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ class EchoApp {
..message = message
..messageCount = count
..messageInterval = 500;
_service.serverStreamingEcho(request).listen((response) {
_addRightMessage(response.message);
}, onError: (error) {
_addRightMessage(error.toString());
}, onDone: () => print('Closed connection to server.'));
_service
.serverStreamingEcho(request)
.listen(
(response) {
_addRightMessage(response.message);
},
onError: (error) {
_addRightMessage(error.toString());
},
onDone: () => print('Closed connection to server.'),
);
}

void _addLeftMessage(String message) {
Expand All @@ -55,13 +61,20 @@ class EchoApp {
}

void _addMessage(String message, String cssClass) {
document.querySelector('#first')!.after(HTMLDivElement()
..classList.add('row')
..append(HTMLHeadingElement.h2()
..append(HTMLSpanElement()
..classList.add('label')
..classList.addAll(cssClass)
..textContent = message)));
document
.querySelector('#first')!
.after(
HTMLDivElement()
..classList.add('row')
..append(
HTMLHeadingElement.h2()..append(
HTMLSpanElement()
..classList.add('label')
..classList.addAll(cssClass)
..textContent = message,
),
),
);
}
}

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

environment:
sdk: ^3.5.0
sdk: ^3.8.0

dependencies:
grpc:
path: ../../
protobuf: ">=3.0.0 <5.0.0"
web: ^1.1.0
protobuf: ^4.1.0
web: ^1.1.1

dev_dependencies:
build_runner: ^2.4.13
build_web_compilers: ^4.0.11
lints: ^5.0.0
build_runner: ^2.4.15
build_web_compilers: ^4.1.5
lints: ^6.0.0
6 changes: 1 addition & 5 deletions example/helloworld/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include: ../../analysis_options.yaml

linter:
rules:
directives_ordering: false
include: package:lints/recommended.yaml
5 changes: 3 additions & 2 deletions example/helloworld/bin/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ Future<void> main(List<String> args) async {
port: 50051,
options: ChannelOptions(
credentials: ChannelCredentials.insecure(),
codecRegistry:
CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
codecRegistry: CodecRegistry(
codecs: const [GzipCodec(), IdentityCodec()],
),
),
);
final stub = GreeterClient(channel);
Expand Down
6 changes: 4 additions & 2 deletions example/helloworld/bin/unix_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ 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);
final udsAddress = InternetAddress(
'localhost',
type: InternetAddressType.unix,
);
final channel = ClientChannel(
udsAddress,
port: 0,
Expand Down
6 changes: 4 additions & 2 deletions example/helloworld/bin/unix_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class GreeterService extends GreeterServiceBase {
}

Future<void> main(List<String> args) async {
final udsAddress =
InternetAddress('localhost', type: InternetAddressType.unix);
final udsAddress = InternetAddress(
'localhost',
type: InternetAddressType.unix,
);
final server = Server.create(services: [GreeterService()]);
await server.serve(address: udsAddress);
print('Start UNIX Server @localhost...');
Expand Down
8 changes: 4 additions & 4 deletions example/helloworld/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ description: Dart gRPC sample client and server.
publish_to: none

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ^3.8.0

dependencies:
async: ^2.2.0
async: ^2.13.0
grpc:
path: ../../
protobuf: ">=3.0.0 <5.0.0"
protobuf: ^4.1.0

dev_dependencies:
lints: ^2.0.0
lints: ^6.0.0
6 changes: 1 addition & 5 deletions example/metadata/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include: ../../analysis_options.yaml

linter:
rules:
directives_ordering: false
include: package:lints/recommended.yaml
38 changes: 24 additions & 14 deletions example/metadata/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ class Client {
late MetadataClient stub;

Future<void> main(List<String> args) async {
channel = ClientChannel('127.0.0.1',
port: 8080,
options:
const ChannelOptions(credentials: ChannelCredentials.insecure()));
channel = ClientChannel(
'127.0.0.1',
port: 8080,
options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
);
stub = MetadataClient(channel);
// Run all of the demos in order.
await runEcho();
Expand All @@ -44,8 +45,10 @@ class Client {
/// metadata.
Future<void> runEcho() async {
final request = Record()..value = 'Kaj';
final call =
stub.echo(request, options: CallOptions(metadata: {'peer': 'Verner'}));
final call = stub.echo(
request,
options: CallOptions(metadata: {'peer': 'Verner'}),
);
call.headers.then((headers) {
print('Received header metadata: $headers');
});
Expand All @@ -62,11 +65,15 @@ class Client {
/// well as a per-call metadata. The server will delay the response for the
/// requested duration, during which the client will cancel the RPC.
Future<void> runEchoDelayCancel() async {
final stubWithCustomOptions = MetadataClient(channel,
options: CallOptions(metadata: {'peer': 'Verner'}));
final stubWithCustomOptions = MetadataClient(
channel,
options: CallOptions(metadata: {'peer': 'Verner'}),
);
final request = Record()..value = 'Kaj';
final call = stubWithCustomOptions.echo(request,
options: CallOptions(metadata: {'delay': '1'}));
final call = stubWithCustomOptions.echo(
request,
options: CallOptions(metadata: {'delay': '1'}),
);
call.headers.then((headers) {
print('Received header metadata: $headers');
});
Expand All @@ -89,8 +96,9 @@ class Client {
/// receiving 3 responses.
Future<void> runAddOneCancel() async {
final numbers = StreamController<int>();
final call =
stub.addOne(numbers.stream.map((value) => Number()..value = value));
final call = stub.addOne(
numbers.stream.map((value) => Number()..value = value),
);
final receivedThree = Completer<bool>();
final sub = call.listen((number) {
print('AddOneCancel: Received ${number.value}');
Expand Down Expand Up @@ -133,8 +141,10 @@ class Client {
/// Call an RPC that returns a stream of Fibonacci numbers, and specify an RPC
/// timeout of 2 seconds.
Future<void> runFibonacciTimeout() async {
final call = stub.fibonacci(Empty(),
options: CallOptions(timeout: Duration(seconds: 2)));
final call = stub.fibonacci(
Empty(),
options: CallOptions(timeout: Duration(seconds: 2)),
);
var count = 0;
try {
await for (var number in call) {
Expand Down
10 changes: 5 additions & 5 deletions example/metadata/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ description: Dart gRPC sample client and server.
publish_to: none

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ^3.8.0

dependencies:
async: ^2.2.0
async: ^2.13.0
grpc:
path: ../../
protobuf: ">=3.0.0 <5.0.0"
protobuf: ^4.1.0

dev_dependencies:
lints: ^2.0.0
test: ^1.6.0
lints: ^6.0.0
test: ^1.26.2
Loading