Skip to content
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

Merge package:bazel_worker #687

Merged
merged 112 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
6056657
initial commit, using OSS template
jakemac53 Apr 11, 2016
6193a6b
Add SyncWorkerLoop and testing helpers
jakemac53 Apr 11, 2016
9b9111b
reorganize MessageGrouperState
jakemac53 Apr 12, 2016
eaaeea6
Use CodedBufferReader to read the length
jakemac53 Apr 12, 2016
259fabb
add AsyncWorkerLoop
jakemac53 Apr 12, 2016
70d8ba3
format
jakemac53 Apr 12, 2016
8dc3e0e
update with strong_mode clean proto generation
jakemac53 Apr 12, 2016
c8ac27e
added shared interfaces, and a few other tweaks
jakemac53 Apr 12, 2016
2fe9942
add a real README with some basic examples
jakemac53 Apr 12, 2016
cc025f9
Fix readme
jakemac53 Apr 13, 2016
3eef52d
expose AsyncMessageGrouper and SyncMessageGrouper in the testing libr…
jakemac53 Apr 15, 2016
e07f3aa
add better error handling when stdin gives an error instead of EOF
jakemac53 Jan 18, 2017
f3884c6
Automatically intercept print calls and append them to reponse.output
jakemac53 Mar 20, 2017
35e6d67
move files under a worker dir, change WorkerConnection#readRequest to…
jakemac53 Apr 5, 2017
e1a0001
Initial version of BazelWorkerDriver
jakemac53 Apr 5, 2017
8cca2e4
update CHANGELOG and pubspec
jakemac53 Apr 4, 2017
bcc70c4
have two lists of workers, one for actively spawning workers and one …
jakemac53 Apr 5, 2017
6147426
update driver comments
jakemac53 Apr 5, 2017
ba249fe
move worker connection impls into worker_connection.dart, updated com…
jakemac53 Apr 5, 2017
e8b31d2
update copyright date
jakemac53 Apr 5, 2017
d637c5c
fix travis script
jakemac53 Apr 5, 2017
28618b3
add driver_test to test_all
jakemac53 Apr 5, 2017
303913c
fix typo
jakemac53 Apr 5, 2017
6907b06
Add an e2e test using the worker and driver from this package (dart-l…
jakemac53 Apr 5, 2017
98bf2b7
attempt to parse invalid protos as strings (dart-lang/bazel_worker#8)
jakemac53 Apr 5, 2017
cbf75d2
Fix fuzzy arrow warning in lib/testing.dart. (dart-lang/bazel_worker#12)
munificent Nov 3, 2017
2e628e6
Update generated proto, declare support for latest async/protobuf (da…
jakemac53 Nov 3, 2017
d1e0e46
Rename .analysis_options to analysis_options.yaml (dart-lang/bazel_wo…
kevmoo Nov 3, 2017
10ea1e6
Add retry logic for failed workers (dart-lang/bazel_worker#15)
jakemac53 Nov 21, 2017
eaeeef2
Add cancel method to `BazelWorkerConnection` and use it (dart-lang/ba…
jakemac53 Nov 27, 2017
063324c
Update worker_protocol.pb.dart using latest protoc compiler plugin. (…
jakobr-google Jan 16, 2018
60ec0fe
Fix incorrect lint, use use non-deprecated method in cli util (dart-l…
kevmoo Jan 16, 2018
d21fd67
Remove upper case constants (dart-lang/bazel_worker#19)
lrhn Apr 17, 2018
7b3a96a
prepare to publish (dart-lang/bazel_worker#20)
jakemac53 May 18, 2018
a7f466f
support the latest protobuf, version 0.9.0 (dart-lang/bazel_worker#24)
jakemac53 Jul 10, 2018
4290894
chore: set max SDK version to <3.0.0 (dart-lang/bazel_worker#25)
chalin Jul 16, 2018
9df65a2
Update e2e example environment constraint (dart-lang/bazel_worker#26)
jakemac53 Aug 16, 2018
cdd93dc
support protobuf 0.11.0 (dart-lang/bazel_worker#28)
jakemac53 Sep 6, 2018
e94a4a3
Support running workers in isolates.
davidmorgan Sep 17, 2018
5a213c7
Changes for code review.
davidmorgan Sep 17, 2018
ba01db4
Changes for code review.
davidmorgan Sep 17, 2018
51a3d9f
Merge pull request dart-lang/bazel_worker#29 from davidmorgan/support…
davidmorgan Sep 17, 2018
13f5a74
Update worker_protocol.pb.dart. (dart-lang/bazel_worker#31)
davidmorgan Oct 22, 2018
347fbb6
Update protobuf output to be compatible with protobuf 0.11.0 (dart-la…
sigurdm Jan 10, 2019
a2753c9
Allow protobuf 0.13.0 (dart-lang/bazel_worker#34)
sigurdm Jan 24, 2019
cfffebd
add trackWork argument to BazelWorkerDriver.doWork (dart-lang/bazel_w…
jakemac53 Jan 28, 2019
86c98c5
Handle null exitCode (dart-lang/bazel_worker#36)
grouma Feb 7, 2019
d10b84b
Close output stream on cancel
grouma Feb 11, 2019
d0ea3c1
Merge pull request dart-lang/bazel_worker#37 from dart-lang/proper-close
grouma Feb 12, 2019
036da7d
Make Stdin act like a Stream<Uint8List> (dart-lang/bazel_worker#39)
tvolkert May 20, 2019
b6f25e1
Delete codereview.settings
kevmoo Aug 1, 2019
ed69f4a
Bump to latest protobuf version (dart-lang/bazel_worker#41)
kevmoo Sep 12, 2019
2706fed
dartfmt --fix, tidy up analysis, protobuf 1.0.0 (dart-lang/bazel_work…
domesticmouse Oct 21, 2019
5b78bdd
Add a tool to build the proto files externally (dart-lang/bazel_worke…
jakemac53 Oct 21, 2019
1ed5b7d
release bazel_worker 0.1.23 (dart-lang/bazel_worker#44)
jakemac53 Oct 21, 2019
0884147
Fix newly enforced package:pedantic lints (dart-lang/bazel_worker#45)
natebosch Dec 13, 2019
b527faa
detect dead workers by a closed input stream instead of exit code (da…
jakemac53 Feb 4, 2020
07c0bed
Detect dead workers by a closed input stream
jakemac53 Feb 4, 2020
c294895
Merge branch 'backport-exit-code-fix'
natebosch May 4, 2020
e26716e
Avoid crashing on closed port in IsolateDriverConnection (dart-lang/b…
michalt Jun 1, 2020
9b56880
Implement isBroadcast for TestStdin (dart-lang/bazel_worker#48)
natebosch Jul 1, 2020
610b4a3
Update README.md
kevmoo Oct 9, 2020
f322b57
Remove unused dart:async imports. (dart-lang/bazel_worker#50)
srawlins Nov 5, 2020
e157ad3
regenerate proto code and fix some new analysis hints (dart-lang/baze…
jakemac53 Nov 12, 2020
7ef6e5e
Migrate bazel_worker to null safety (dart-lang/bazel_worker#52)
iinozemtsev Nov 17, 2020
f48d8d9
Migrate to GitHub Actions (dart-lang/bazel_worker#53)
athomas Dec 21, 2020
31652f8
Optimize `AsyncMessageGrouper`. (dart-lang/bazel_worker#54)
davidmorgan Mar 8, 2021
48ba07b
Update LICENSE
franklinyow Mar 31, 2021
e9486b5
Merge pull request dart-lang/bazel_worker#55 from dart-lang/frankliny…
franklinyow Mar 31, 2021
bcb68d0
Update CI setup (dart-lang/bazel_worker#56)
kevmoo Apr 27, 2021
2c77750
Change "dartfmt" -> "dart format". (dart-lang/bazel_worker#57)
munificent Oct 1, 2021
ef8467e
Migrate to pkg:lints, fix associated lints (dart-lang/bazel_worker#58)
kevmoo Oct 4, 2021
599c6af
Prepare to release v1.0.1 (dart-lang/bazel_worker#59)
kevmoo Oct 5, 2021
b528d5b
Expand description, add example (dart-lang/bazel_worker#60)
natebosch Nov 10, 2021
7b67c37
Fix CI (dart-lang/bazel_worker#61)
kevmoo Mar 21, 2022
0ad0696
Update pubspec.yaml (dart-lang/bazel_worker#62)
devoncarew Apr 19, 2022
0b5184c
Prepare to publish (dart-lang/bazel_worker#63)
natebosch Oct 18, 2022
e436fb3
Fix changelog mention of required SDK version (dart-lang/bazel_worker…
parlough Oct 19, 2022
a5d11d8
blast_repo fixes (dart-lang/bazel_worker#65)
kevmoo Nov 10, 2022
72dbf29
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/bazel_worker#66)
dependabot[bot] Jan 3, 2023
81df5d3
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/bazel_worker#68)
dependabot[bot] Feb 1, 2023
99ec5ca
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/bazel_worker#67)
dependabot[bot] Feb 1, 2023
d73f6b6
Migrate to dart_flutter_team_lints, cleanup (dart-lang/bazel_worker#69)
kevmoo Feb 9, 2023
80bc129
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/bazel_worker#71)
dependabot[bot] Apr 3, 2023
16254e9
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/bazel_worker…
dependabot[bot] Apr 3, 2023
b387bf0
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/bazel_worker#72)
dependabot[bot] May 2, 2023
5dbb76d
blast_repo fixes (dart-lang/bazel_worker#73)
devoncarew May 12, 2023
4354c02
Bump lints, regenerate proto file, fix script (dart-lang/bazel_worker…
kevmoo May 31, 2023
31030a9
Require protobuf 3.0.0 and prepare for 1.0.3 release (dart-lang/bazel…
parlough Jun 16, 2023
2e3d054
add firehose publishing workflow (dart-lang/bazel_worker#76)
jakemac53 Jun 16, 2023
68f3d6d
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/bazel_worker#77)
dependabot[bot] Jul 1, 2023
e5f79d2
Update e2e_test dependencies (dart-lang/bazel_worker#79)
parlough Aug 30, 2023
d0cee4d
Regenerate worker protocol protos to add constructors and comments (d…
parlough Aug 31, 2023
613a61e
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/bazel_worker#80)
dependabot[bot] Sep 1, 2023
2823af2
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/bazel_worker…
dependabot[bot] Oct 1, 2023
bc7de7f
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/bazel_worker#82)
dependabot[bot] Oct 2, 2023
f1b5748
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/bazel_worker…
dependabot[bot] Nov 1, 2023
6d3ba7d
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/bazel_worker#83)
dependabot[bot] Nov 2, 2023
38ee10a
Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/bazel_worker…
dependabot[bot] Feb 1, 2024
8adc6fc
Fix bug around handling of failures in `spawnWorker` calls (dart-lang…
jakemac53 Mar 7, 2024
1fd7a25
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/bazel_worker#88)
dependabot[bot] Apr 1, 2024
8014da1
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/bazel_worker…
dependabot[bot] May 1, 2024
0bf0a05
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/bazel_worker#89)
dependabot[bot] May 2, 2024
36c124b
blast_repo fixes (dart-lang/bazel_worker#91)
devoncarew May 3, 2024
e9a612e
bump lints dep and fix (dart-lang/bazel_worker#92)
kevmoo May 28, 2024
f693bf6
Bump actions/checkout from 4.1.4 to 4.1.6 in the github-actions group…
dependabot[bot] Jun 1, 2024
871ad9b
blast_repo fixes (dart-lang/bazel_worker#94)
kevmoo Jul 1, 2024
c6a7b57
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] Oct 1, 2024
4ff00fc
Merge package:bazel_worker into the tools monorepo
mosuem Oct 25, 2024
f8659c3
Add issue template and other fixes
mosuem Oct 25, 2024
ad324b4
Moving fixes
mosuem Oct 25, 2024
2104095
Update .github/workflows/bazel_worker.yaml
mosuem Oct 29, 2024
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
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/bazel_worker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:bazel_worker"
about: "Create a bug or file a feature request against package:bazel_worker."
labels: "package:bazel_worker"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- changed-files:
- any-glob-to-any-file: '.github/**'

'package:bazel_worker':
- changed-files:
- any-glob-to-any-file: 'pkgs/bazel_worker/**'

'package:boolean_selector':
- changed-files:
- any-glob-to-any-file: 'pkgs/boolean_selector/**'
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/bazel_worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: package:bazel_worker

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/bazel_worker.yml'
- 'pkgs/bazel_worker/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/bazel_worker.yml'
- 'pkgs/bazel_worker/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/bazel_worker/

jobs:
mosuem marked this conversation as resolved.
Show resolved Hide resolved
# Run the test script against the latest dev build.
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [3.1.0, dev]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- run: "dart format --output=none --set-exit-if-changed ."
- name: Test
run: ./tool/travis.sh
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ don't naturally belong to other topic monorepos (like

| Package | Description | Version |
| --- | --- | --- |
| [bazel_worker](pkgs/bazel_worker/) | Protocol and utilities to implement or invoke persistent bazel workers. | [![pub package](https://img.shields.io/pub/v/bazel_worker.svg)](https://pub.dev/packages/bazel_worker) |
| [boolean_selector](pkgs/boolean_selector/) | A flexible syntax for boolean expressions, based on a simplified version of Dart's expression syntax. | [![pub package](https://img.shields.io/pub/v/boolean_selector.svg)](https://pub.dev/packages/boolean_selector) |
| [cli_config](pkgs/cli_config/) | A library to take config values from configuration files, CLI arguments, and environment variables. | [![pub package](https://img.shields.io/pub/v/cli_config.svg)](https://pub.dev/packages/cli_config) |
| [coverage](pkgs/coverage/) | Coverage data manipulation and formatting. | [![pub package](https://img.shields.io/pub/v/coverage.svg)](https://pub.dev/packages/coverage) |
Expand Down
10 changes: 10 additions & 0 deletions pkgs/bazel_worker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.buildlog
.DS_Store
.idea
.pub/
.settings/
build/
packages
.packages
pubspec.lock
.dart_tool
6 changes: 6 additions & 0 deletions pkgs/bazel_worker/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
189 changes: 189 additions & 0 deletions pkgs/bazel_worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
## 1.1.2

* Require Dart SDK `^3.1.0`.
* Move to `dart-lang/tools` monorepo.

## 1.1.1

* Fix a bug where if spawnWorker threw an error, work requests would hang
forever instead of failing.

## 1.1.0

* Add constructors with named parameters to
the generated worker protocol messages.
* Include comments on the generated worker protocol API.

## 1.0.3

* Require `package:protobuf` >= 3.0.0.
* Require Dart SDK >= 2.19.0

## 1.0.2

* Expand pub documentation to improve pub score.

## 1.0.1

* Require Dart SDK >=2.14.0
* Drop dependency on `package:pedantic`.

## 1.0.0

* Improve `AsyncMessageGrouper` performance.
* Add `benchmark/benchmark.dart` measuring `AsyncMessageGrouper` performance.

## 1.0.0-nullsafety.0

* Migrate to null safety.
* Use `WorkResponse` with `exitCode` set to `EXIT_CODE_BROKEN_PIPE` instead of
`null` responses.

## 0.1.25+1-dev

* Regenerate proto code and fix some new analysis hints.

## 0.1.25

* Add `isBroadcast` implementation to `TestStdin` classes.

## 0.1.24

* Check for closed port when trying to read a response in
`IsolateDriverConnection` and return `null` if there is nothing to be read.

## 0.1.23+1

* Don't rely on `exitCode` to know when a worker terminates, instead wait for
the input stream to close.
* The SDK may also start throwing instead of returning a `null` here, so this
pre-emptively guards against that.

## 0.1.23

* Support protobuf `1.x`.
* Added a tool for updating generated proto files and updated them
using the latest version of the protoc_plugin package.
* This required a lower bound bump of the `protobuf` package to `0.14.4`.

## 0.1.22

* Require protobuf 0.14.0.

## 0.1.21+1

* Don't rely on `exitCode` to know when a worker terminates, instead wait for
the input stream to close. Backport of fix in `0.1.23+1` in a version that
does not require a newer protobuf.

## 0.1.21

* Make `TestStdinAsync` behave like a `Stream<Uint8List>`

## 0.1.20

* Close worker `outputStream` on `cancel`.

## 0.1.19

* Work around https://github.com/dart-lang/sdk/issues/35874.

## 0.1.18

* Add a `trackWork` optional named argument to `BazelDriver.doWork`. This allows
the caller to know when a work request is actually sent to a worker.

## 0.1.17

* Allow protobuf 0.13.0.

## 0.1.16

* Update the worker_protocol.pb.dart file with the latest proto generator.
* Require protobuf 0.11.0.

## 0.1.15

* Update the worker_protocol.pb.dart file with the latest proto generator.
* Require protobuf 0.10.4.

## 0.1.14

* Allow workers to support running in isolates. To support running in isolates,
workers must modify their `main` method to accept a `SendPort` then use it
when creating the `AsyncWorkerConnection`. See `async_worker` in `e2e_test`.

## 0.1.13

* Support protobuf 0.10.0.

## 0.1.12

* Set max SDK version to `<3.0.0`.

## 0.1.11

* Added support for protobuf 0.9.0.

## 0.1.10

* Update the SDK dependency to 2.0.0-dev.17.0.
* Update to protobuf version 0.8.0
* Remove usages of deprecated upper-case constants from the SDK.

## 0.1.9

* Update the worker_protocol.pb.dart file with the latest proto generator.

## 0.1.8

* Add `Future cancel()` method to `DriverConnection`, which in the case of a
`StdDriverConnection` closes the input stream.
* The `terminateWorkers` method on `BazelWorkerDriver` now calls `cancel` on
all worker connections to ensure the vm can exit correctly.

## 0.1.7

* Update the `BazelWorkerDriver` class to handle worker crashes, and retry work
requests. The number of retries is configurable with the new `int maxRetries`
optional arg to the `BazelWorkerDriver` constructor.

## 0.1.6

* Update the worker_protocol.pb.dart file with the latest proto generator.
* Add support for package:async 2.x and package:protobuf 6.x.

## 0.1.5

* Change TestStdinAsync.controller to StreamController<List<int>> (instead of
using dynamic as the type argument).

## 0.1.4

* Added `BazelWorkerDriver` class, which can be used to implement the bazel side
of the protocol. This allows you to speak to any process which knows the bazel
protocol from your own process.
* Changed `WorkerConnection#readRequest` to return a `FutureOr<WorkRequest>`
instead of dynamic.

## 0.1.3

* Add automatic intercepting of print calls and append them to
`response.output`. This makes more libraries work out of the box, as printing
would previously cause an error due to communication over stdin/stdout.
* Note that using stdin/stdout directly will still cause an error, but that is
less common.

## 0.1.2

* Add better handling for the case where stdin gives an error instead of an EOF.

## 0.1.1

* Export `AsyncMessageGrouper` and `SyncMessageGrouper` as part of the testing
library. These can assist when writing e2e tests and communicating with a
worker process.

## 0.1.0

* Initial version.
27 changes: 27 additions & 0 deletions pkgs/bazel_worker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2016, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 changes: 66 additions & 0 deletions pkgs/bazel_worker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Tools for creating a persistent worker loop for [bazel](https://bazel.build/).

## Usage

There are two abstract classes provided by this package, `AsyncWorkerLoop` and
`SyncWorkerLoop`. These each have a `performRequest` method which you must
implement.

Lets look at a simple example of a `SyncWorkerLoop` implementation:

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

void main() {
// Blocks until it gets an EOF from stdin.
SyncSimpleWorker().run();
}

class SyncSimpleWorker extends SyncWorkerLoop {
/// Must synchronously return a [WorkResponse], since this is a
/// [SyncWorkerLoop].
WorkResponse performRequest(WorkRequest request) {
File('hello.txt').writeAsStringSync('hello world!');
return WorkResponse()..exitCode = EXIT_CODE_OK;
}
}
```

And now the same thing, implemented as an `AsyncWorkerLoop`:

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

void main() {
// Doesn't block, runs tasks async as they are received on stdin.
AsyncSimpleWorker().run();
}

class AsyncSimpleWorker extends AsyncWorkerLoop {
/// Must return a [Future<WorkResponse>], since this is an
/// [AsyncWorkerLoop].
Future<WorkResponse> performRequest(WorkRequest request) async {
await File('hello.txt').writeAsString('hello world!');
return WorkResponse()..exitCode = EXIT_CODE_OK;
}
}
```

As you can see, these are nearly identical, it mostly comes down to the
constraints on your package and personal preference which one you choose to
implement.

## Testing

A `package:bazel_worker/testing.dart` file is also provided, which can greatly
assist with writing unit tests for your worker. See the
`test/worker_loop_test.dart` test included in this package for an example of how
the helpers can be used.

## Features and bugs

Please file feature requests and bugs at the [issue tracker][tracker].

[tracker]: https://github.com/dart-lang/tools/issues
13 changes: 13 additions & 0 deletions pkgs/bazel_worker/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://dart.dev/guides/language/analysis-options
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
errors:
# For the generated file
lines_longer_than_80_chars: ignore

linter:
rules:
- package_api_docs
Loading
Loading