shelf_serve_isolates 1.1.0 copy "shelf_serve_isolates: ^1.1.0" to clipboard
shelf_serve_isolates: ^1.1.0 copied to clipboard

Shelf server with multi-isolates.

Shelf server with multi-isolates.

Features #

  • Start shelf server on multiple isolates.
  • Graceful shutdown with in docker containers.

Usage #

See /example folder.

import 'dart:async';

import 'package:shelf/shelf.dart';
import 'package:shelf_serve_isolates/shelf_serve_isolates.dart';

Future<void> serve({int port = 8080}) async {
  final handler =
      const Pipeline().addMiddleware(logRequests()).addHandler(_echoRequest);

  await ServeWithMultiIsolates(
    handler: handler,
    address: 'localhost',
    port: port,
    onStart: (server) {
      print('Serving at http://${server.address.host}:${server.port}');
    },
    onClose: (server) {
      print('server shutdown');
    },
  ).serve();
}

Future<Response> _echoRequest(Request request) async {
  return Response.ok('Request for "${request.url}"');
}
2
likes
150
points
71
downloads

Publisher

verified publisherkkazuo.com

Weekly Downloads

Shelf server with multi-isolates.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

shelf, shelf_docker_shutdown

More

Packages that depend on shelf_serve_isolates