Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
bump lints dep and fix (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored May 28, 2024
1 parent 2fb4fbf commit 2ec90c0
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [2.19.0, dev]
sdk: [3.1.0, dev]
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.2-wip

* Require Dart SDK `^3.1.0`.

## 1.1.1

* Fix a bug where if spawnWorker threw an error, work requests would hang
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async_message_grouper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AsyncMessageGrouper implements MessageGrouper {
/// Position in the current input buffer.
int _inputBufferPos = 0;

/// Completes after [cancel] is called or [inputStream] is closed.
/// Completes after [cancel] is called or `inputStream` is closed.
Future<void> get done => _done.future;
final _done = Completer<void>();

Expand Down
8 changes: 4 additions & 4 deletions lib/src/driver/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BazelWorkerDriver {
/// The maximum number of idle workers at any given time.
final int _maxIdleWorkers;

/// The maximum number of times to retry a [WorkAttempt] if there is an error.
/// The maximum number of times to retry a [_WorkAttempt] if there is an error.
final int _maxRetries;

/// The maximum number of concurrent workers to run at any given time.
Expand Down Expand Up @@ -57,7 +57,7 @@ class BazelWorkerDriver {
/// to determine when actual work is being done versus just waiting for an
/// available worker.
Future<WorkResponse> doWork(WorkRequest request,
{Function(Future<WorkResponse?>)? trackWork}) {
{void Function(Future<WorkResponse?>)? trackWork}) {
var attempt = _WorkAttempt(request, trackWork: trackWork);
_workQueue.add(attempt);
_runWorkQueue();
Expand Down Expand Up @@ -130,7 +130,7 @@ class BazelWorkerDriver {
_runWorkQueue();
}

/// Sends [request] to [worker].
/// Sends [attempt] to [worker].
///
/// Once the worker responds then it will be added back to the pool of idle
/// workers.
Expand Down Expand Up @@ -227,7 +227,7 @@ class BazelWorkerDriver {
class _WorkAttempt {
final WorkRequest request;
final responseCompleter = Completer<WorkResponse>();
final Function(Future<WorkResponse?>)? trackWork;
final void Function(Future<WorkResponse?>)? trackWork;

Future<WorkResponse> get response => responseCompleter.future;

Expand Down
1 change: 1 addition & 0 deletions lib/src/driver/driver_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:isolate';

import '../async_message_grouper.dart';
import '../constants.dart';
import '../message_grouper.dart';
import '../utils.dart';
import '../worker_protocol.pb.dart';

Expand Down
3 changes: 3 additions & 0 deletions lib/src/message_grouper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'async_message_grouper.dart';
import 'sync_message_grouper.dart';

/// Interface for a [MessageGrouper], which groups bytes in delimited proto
/// format into the bytes for each message.
///
Expand Down
4 changes: 3 additions & 1 deletion lib/src/message_grouper_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'dart:typed_data';

import 'package:protobuf/protobuf.dart';

import 'message_grouper.dart';

/// State held by the [MessageGrouper] while waiting for additional data to
/// arrive.
class MessageGrouperState {
Expand All @@ -18,7 +20,7 @@ class MessageGrouperState {
/// Handle one byte at a time.
///
/// Returns a [List<int>] of message bytes if [byte] was the last byte in a
/// message, otherwise returns [null].
/// message, otherwise returns `null`.
List<int>? handleInput(int byte) {
if (!_lengthReader.done) {
_lengthReader.readByte(byte);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/worker/worker_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import '../worker_protocol.pb.dart';
/// program using `BazelWorkerDriver`, or any other process that speaks the
/// protocol).
abstract class WorkerConnection {
/// Reads a [WorkRequest] or returns [null] if there are none left.
/// Reads a [WorkRequest] or returns `null` if there are none left.
///
/// See [AsyncWorkerConnection] and [SyncWorkerConnection] for more narrow
/// interfaces.
Expand Down
4 changes: 3 additions & 1 deletion lib/src/worker/worker_loop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

import '../worker_protocol.pb.dart';
import 'async_worker_loop.dart';
import 'sync_worker_loop.dart';

/// Interface for a [WorkerLoop].
///
Expand All @@ -13,6 +15,6 @@ abstract class WorkerLoop {
/// a [Future<WorkResponse>].
dynamic performRequest(WorkRequest request);

/// Run the worker loop. Should return either a [Future] or [null].
/// Run the worker loop. Should return either a [Future] or `null`.
dynamic run();
}
6 changes: 3 additions & 3 deletions lib/testing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:collection';
import 'dart:io';
import 'dart:typed_data';

import 'package:bazel_worker/bazel_worker.dart';
import 'bazel_worker.dart';

export 'src/async_message_grouper.dart';
export 'src/sync_message_grouper.dart';
Expand Down Expand Up @@ -150,7 +150,7 @@ class TestSyncWorkerLoop extends SyncWorkerLoop implements TestWorkerLoop {
}

/// Adds [response] to the queue. These will be returned from
/// [performResponse] in the order they are added, otherwise it will throw
/// [performRequest] in the order they are added, otherwise it will throw
/// if the queue is empty.
@override
void enqueueResponse(WorkResponse response) {
Expand Down Expand Up @@ -194,7 +194,7 @@ class TestAsyncWorkerLoop extends AsyncWorkerLoop implements TestWorkerLoop {
}

/// Adds [response] to the queue. These will be returned from
/// [performResponse] in the order they are added, otherwise it will throw
/// [performRequest] in the order they are added, otherwise it will throw
/// if the queue is empty.
@override
void enqueueResponse(WorkResponse response) {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: bazel_worker
version: 1.1.1
version: 1.1.2-wip
description: >-
Protocol and utilities to implement or invoke persistent bazel workers.
repository: https://github.com/dart-lang/bazel_worker

environment:
sdk: '>=2.19.0 <4.0.0'
sdk: ^3.1.0

dependencies:
async: ^2.5.0
protobuf: ^3.0.0

dev_dependencies:
dart_flutter_team_lints: ^1.0.0
dart_flutter_team_lints: ^3.0.0
test: ^1.16.0
5 changes: 2 additions & 3 deletions test/driver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void main() {
Future _doRequests(
{BazelWorkerDriver? driver,
int count = 100,
Function(Future<WorkResponse?>)? trackWork}) async {
void Function(Future<WorkResponse?>)? trackWork}) async {
// If we create a driver, we need to make sure and terminate it.
var terminateDriver = driver == null;
driver ??= BazelWorkerDriver(MockWorker.spawn);
Expand All @@ -178,8 +178,7 @@ Future _doRequests(
class MockWorkerLoop extends AsyncWorkerLoop {
final Queue<WorkResponse> _responseQueue;

MockWorkerLoop(this._responseQueue, {AsyncWorkerConnection? connection})
: super(connection: connection);
MockWorkerLoop(this._responseQueue, {super.connection});

@override
Future<WorkResponse> performRequest(WorkRequest request) async {
Expand Down
2 changes: 1 addition & 1 deletion test/worker_loop_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void runTests<T extends TestWorkerConnection>(
(stdinStream as TestStdinSync).pendingBytes.clear();
await workerLoop.run();
} else if (stdinStream is TestStdinAsync) {
var done = Completer();
var done = Completer<void>();
// ignore: avoid_dynamic_calls
workerLoop.run().then((_) => done.complete(null));
(stdinStream as TestStdinAsync).controller.addError('Error!!');
Expand Down

0 comments on commit 2ec90c0

Please sign in to comment.