pub repository
mirror.p-hatan.irbazel_worker
0.1.15Tools for creating a bazel persistent worker.
Readme
Tools for creating a persistent worker loop for bazel.
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:
import 'dart:io';
import 'package:bazel_worker/bazel_worker.dart';
void main() {
// Blocks until it gets an EOF from stdin.
new SyncSimpleWorker().run();
}
class SyncSimpleWorker extends SyncWorkerLoop {
/// Must synchronously return a [WorkResponse], since this is a
/// [SyncWorkerLoop].
WorkResponse performRequest(WorkRequest request) {
new File('hello.txt').writeAsStringSync('hello world!');
return new WorkResponse()..exitCode = EXIT_CODE_OK;
}
}
And now the same thing, implemented as an AsyncWorkerLoop:
import 'dart:io';
import 'package:bazel_worker/bazel_worker.dart';
void main() {
// Doesn't block, runs tasks async as they are received on stdin.
new AsyncSimpleWorker().run();
}
class AsyncSimpleWorker extends AsyncWorkerLoop {
/// Must return a [Future<WorkResponse>], since this is an
/// [AsyncWorkerLoop].
Future<WorkResponse> performRequest(WorkRequest request) async {
await new File('hello.txt').writeAsString('hello world!');
return new 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.
Changelog
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
mainmethod to accept aSendPortthen use it when creating theAsyncWorkerConnection. Seeasync_workerine2e_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 toDriverConnection, which in the case of aStdDriverConnectioncloses the input stream.- The
terminateWorkersmethod onBazelWorkerDrivernow callscancelon all worker connections to ensure the vm can exit correctly.
- The
0.1.7
- Update the
BazelWorkerDriverclass to handle worker crashes, and retry work requests. The number of retries is configurable with the newint maxRetriesoptional arg to theBazelWorkerDriverconstructor.
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> (instead of using dynamic as the type argument).
0.1.4
- Added
BazelWorkerDriverclass, 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#readRequestto return aFutureOr<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
AsyncMessageGrouperandSyncMessageGrouperas part of the testing library. These can assist when writing e2e tests and communicating with a worker process.
0.1.0
- Initial version.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add bazel_workerpubspec.yaml
name: bazel_worker
version: 0.1.15
description: Tools for creating a bazel persistent worker.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/bazel_worker
environment:
sdk: '>=2.0.0-dev.17.0 <3.0.0'
dependencies:
async: '>1.9.0 <3.0.0'
protobuf: '>=0.10.4 <0.11.0'
dev_dependencies:
test: ^1.2.0
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | 2016-04-13T16:46:28.330Z | Download | b410f8f142b49e4e13ad35150d8b0f35fa324bc4d246d9b91b9487483d5dd94d |
| 0.1.1 | 2016-04-15T19:15:42.294Z | Download | ccddcfd73b1c8f8c7c84ae9caf8613eb025f2ac850c9bd1b4d180d145139d20a |
| 0.1.2 | 2017-01-19T20:21:42.190Z | Download | 946c12da145ec48934e4142a4eed36360b6cdc02acd68f2381237c6210a1d9d3 |
| 0.1.3 | 2017-03-20T17:31:03.933948Z | Download | ac81714613d59fe3fa40651362012d9bd151762f6f10f5c22be31b74d955f85b |
| 0.1.4 | 2017-04-05T19:18:11.352112Z | Download | a235bb710d5ec302ab0c817ee6da7af991a4b5790ef25821efef13d9364a7111 |
| 0.1.5 | 2017-11-03T17:15:30.768658Z | Download | 00434474d49d9af23838c94ebe0a64097360f36f14edf7fee7357ac56c73b78e |
| 0.1.6 | 2017-11-03T18:21:35.638369Z | Download | 1bd5d2d731f5fafccc434d2621fd10313f586661448ec75425a4a929a55814fb |
| 0.1.7 | 2017-11-21T17:06:57.964933Z | Download | 89fb7d10aecf6b5b15b305e07df99164b3b49de4348c2d02a21ee26f348f9dcd |
| 0.1.8 | 2017-11-27T22:23:08.693586Z | Download | b627ae9127f59ca38e604b1c368e51e531433bf4423bc97a7bb79c860959a52f |
| 0.1.9 | 2018-01-16T14:59:32.691859Z | Download | d5eee2150c83bba8a51af3dc4adcae2291cd4d6df34e1b6908030e05e0e64231 |
| 0.1.10 | 2018-05-18T16:45:01.816966Z | Download | 5bac6e844cef9fcfe50dcec179cb4ef2db170e080fd1e10e6fa43499ac6edd2c |
| 0.1.11 | 2018-07-10T16:49:41.533567Z | Download | 7df2c2867bb5895b1c585df72342e85f5947eeb7cb4068315b3b2f32e12f1a1b |
| 0.1.12 | 2018-07-16T15:47:28.434193Z | Download | ef593a5147eacfbd6e23321f6c142b05743ddda928462f2ba8742b58ddb661c0 |
| 0.1.13 | 2018-09-06T14:37:54.837103Z | Download | 91750e77a6dccceb1d406d67a30deca617c093109a3a9b305bd700cf5e222d88 |
| 0.1.14 | 2018-09-17T14:48:46.938515Z | Download | 7fd2ceca540b24d7457602c0ed941240f1f5a3fbb649bb4cd5765852f9b78a41 |
| 0.1.15 | 2018-10-22T17:19:07.489773Z | Download | 9f5fe140684000f47378cebf3ad7779a6838bab1633194f154c550b7c7ec6e9c |
| 0.1.16 | 2019-01-10T15:19:55.765654Z | Download | 0436c07c56035753d2b40c42c14a25f31eb4aca16e3ed4a2f2cdd58c0a515f78 |
| 0.1.17 | 2019-01-24T16:27:16.046156Z | Download | 21c6b6dc0837674063b604154a3d22f71a720cb6f0af78276a7f9099bd04bb99 |
| 0.1.18 | 2019-01-28T22:28:44.118055Z | Download | e43a5ba6f15e39dfc97b56930db1f0501ed208c1c82110ed628c0bae211782c4 |
| 0.1.19 | 2019-02-07T16:12:43.132859Z | Download | 5f16c3aba9b8b31365074319190e5d1262a50b20f35781217675e876c5ac2c5c |
| 0.1.20 | 2019-02-12T18:40:20.050189Z | Download | 4769d7df87e70b2c91f3dc68138eaab4aa8d5fb0cb65d29c76d04f9611f7ab9d |
| 0.1.21 | 2019-05-20T16:22:48.651195Z | Download | a92e8d7f53c2320579ecfa7949945668c4e9f53fc07084d1fdec6f39239369e6 |
| 0.1.21+1 | 2020-05-04T18:06:09.251491Z | Download | 0fdcb200ab59642fb8761771d3a3525b4e4b3256333f85525da49ad0df364418 |
| 0.1.22 | 2019-09-12T16:02:19.089392Z | Download | 9b78011b0a317044319457e330bd02d62d32bc1e83d8a893ffc9b9c7a8bfa0c7 |
| 0.1.23 | 2019-10-21T15:54:16.173085Z | Download | 77e75dc02602d8a950e54fdb7d0bd46de1dd798d3e7f064b6a9c1dcd62398993 |
| 0.1.23+1 | 2020-02-04T22:36:33.879184Z | Download | 7f5e24bf54d7402a8748f35da421d4d7ea0d26b016f3d8b3d11e23158b269305 |
| 0.1.24 | 2020-06-01T13:51:35.751385Z | Download | cc64734920627c2f2af6e400d687be63eaa1d83b7ab76e248b9e40aae1761ca1 |
| 0.1.25 | 2020-07-06T19:52:40.773623Z | Download | 45aea72e83bd3ed8923d51a5614c87cc04fa8ffb8392ddfb506db8126383cc62 |
| 1.0.0-nullsafety.0 | 2021-02-04T15:59:27.277527Z | Download | efaa4d7aa4191bc794ea3faf0db769a83ab0d45c26b849910f7b9f94bb37abaf |
| 1.0.0 | 2021-03-08T16:58:12.511197Z | Download | 8a10b711ceead25ed7c42e135679efe7e27fe8cd9989fa5cd630a9c5731ddc6c |
| 1.0.1 | 2021-10-05T16:43:03.515317Z | Download | b0f16544323bfc3ba1d879e6b65eee07508009023d51e89978f261cf9853187f |
| 1.0.2 | 2022-10-18T16:48:04.156342Z | Download | 500584fdb80bcb70a2990a5838338a757cc24bbf27d88bf791cbe9461c57cd5a |
| 1.0.3 | 2023-06-16T15:44:36.331803Z | Download | 6aa1de567844e1a1db3ac16959159b31a71128fdd27d63d861ad5aa7299e48c5 |
| 1.1.0 | 2023-08-31T18:08:38.831490Z | Download | 6f306845d941808bed2fdbd7db3a39de273a8248a9303cfebf0cfa861372616e |
| 1.1.1 | 2024-03-07T16:06:03.914986Z | Download | 4eef19cc486c289e4b06c69d0f6f3192e85cc93c25d4d15d02afb205e388d2f0 |
| 1.1.2 | 2024-10-29T14:35:02.583620Z | Download | 57035594b87d9f5af99f1a80e1edf5411dadbdf5acfc4f90403e3849f57dd0f0 |
| 1.1.3 | 2025-04-01T17:47:48.076117Z | Download | 373a6ef07caa6c674c1cf144a5fe1e0f712c040552031ce669f298e35f7e110a |
| 1.1.4 | 2025-10-07T07:42:28.435856Z | Download | 47e5106e06dcbfd7382b903b676d48974387b8612ca470f6c54f367ca90da32b |
| 1.1.5 | 2025-12-02T19:41:17.023023Z | Download | 87cae9150fcf9942b8057e5f51c4848a3efde1289e97411e1c8f01e350120999 |
Dependencies
async "\u003e1.9.0 \u003c3.0.0"
protobuf "\u003e=0.10.4 \u003c0.11.0"