Skip to main content

bare_stow_host 0.1.0 copy "bare_stow_host: ^0.1.0" to clipboard
bare_stow_host: ^0.1.0 copied to clipboard

Host side of the bare-stow lifecycle for Dart, layering readiness, termination, and exit reporting over a byte transport to a stowed bundle.

bare-stow-host-dart #

Host side of the bare-stow lifecycle for Dart. The Dart counterpart of bare-stow-host: it multiplexes a control channel and a user data channel over a byte transport to a stowed bundle, and layers readiness, termination, and exit reporting on top.

dart pub add bare_stow_host

Usage #

import 'dart:convert';

import 'package:bare_kit/bare_kit.dart';
import 'package:bare_stow_host/bare_stow_host.dart';

Future<void> main() async {
  final worklet = Worklet.start('index.bundle');

  final ipc = Ipc(worklet, worklet, kill: worklet.destroy);

  worklet.exitCode.then(ipc.exited);

  await ipc.ready;

  ipc.add(utf8.encode('hello'));

  final code = await ipc.terminate();
}

Any Stream<List<int>> and StreamSink<List<int>> can be wrapped, such as a Worklet from bare-kit-dart. Listening to the Ipc yields the user data from the worker, and adding to it sends user data to the worker.

Whoever creates the Ipc must call ipc.exited(code, signal: signal) once the worker has exited, such as when the process of a sidecar exits. Until then, a transport that ends or fails without the worker saying why is held back, so that the Ipc can fail with the exit code or signal. A worker whose transport fails and that hasn't exited within the grace period is killed.

Protocol #

Every frame is a 4-byte little-endian length followed by that many bytes: A 1-byte tag and the payload. The tag is 0x00 for a control frame, whose payload is a UTF-8 JSON object carrying its type, and 0x01 for a user data frame. See bare-stow-protocol for the control frames.

License #

Apache-2.0

0
likes
145
points
703
downloads

Documentation

API reference

Publisher

verified publishertether.io

Weekly Downloads

Host side of the bare-stow lifecycle for Dart, layering readiness, termination, and exit reporting over a byte transport to a stowed bundle.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

More

Packages that depend on bare_stow_host