The Protevus Platform: Unified Full-Stack Development https://protevus.com
Find a file
2019-04-29 01:10:27 -04:00
example Add bind 2019-04-26 19:22:30 -04:00
lib Basic listen works 2019-04-29 01:10:27 -04:00
web Basic README 2018-07-10 11:06:29 -04:00
.gitignore Dart VM is broken 2019-04-27 15:12:09 -04:00
analysis_options.yaml Redesign 2019-04-26 19:11:58 -04:00
configure Dart VM is broken 2019-04-27 15:12:09 -04:00
Makefile Basic listen works 2019-04-29 01:10:27 -04:00
Makefile.old Add config script 2019-04-26 19:26:12 -04:00
pubspec.yaml Redesign 2019-04-26 19:11:58 -04:00
README.md Basic README 2018-07-10 11:06:29 -04:00

wings

Native HTTP driver for Angel, for a nice speed boost.

Not ready for production.

How does it work?

Typically, Angel uses the AngelHttp driver, which is wrapper over the HttpServer functionality in dart:io, which in turns uses the ServerSocket and Socket functionality. This is great - Dart's standard library comes with an HTTP server, which saves a lot of difficult in implementation.

However, abstraction tends to come with a cost. Wings seeks to minimize abstraction entirely. Rather than using the built-in Dart network stack, Wings' HTTP server is implemented in C++ as a Dart native extension, and the AngelWings driver listens to events from the extension and converts them directly into RequestContext objects, without any additional abstraction within. This reduces the amount of computation performed on each request, and helps to minimize response latency. Sending data from the response buffer in plain Dart surprisingly is the most expensive operation, as is revealed by the Observatory.

By combining Dart's powerful VM with a native code server based on the same one used in Node.js, AngelWings trims several milliseconds off every request, both saving resources and reducing load times for high-traffic applications.

How can I use it?

The intended way to use AngelWings is via package:build_native; however, the situation surrounding distributing native extensions is yet far from ideal, so this package includes pre-built binaries out-of-the-box.

Thanks to this, you can use it like any other Dart package, by installing it via Pub.

Brief example

Using AngelWings is almost identical to using AngelHttp; however, it does not support SSL, and therefore should be placed behind a reverse proxy like nginx in production.

main() async {
  var app = new Angel();
  var wings = new AngelWings(app, shared: true, useZone: false);

  app.injectEncoders({'gzip': gzip.encoder, 'deflate': zlib.encoder});

  app.get('/hello', 'Hello, native world! This is Angel WINGS.');

  var fs = const LocalFileSystem();
  var vDir = new VirtualDirectory(app, fs, source: fs.directory('web'));
  app.use(vDir.handleRequest);

  await wings.startServer('127.0.0.1', 3000);
  print('Listening at http://${wings.address.address}:${wings.port}');
}