shelf_serve_isolates

Last updated:

0 purchases

shelf_serve_isolates Image
shelf_serve_isolates Images
Add to Cart

Description:

shelf serve 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}"');
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.