diff --git a/packages/production/CHANGELOG.md b/packages/production/CHANGELOG.md index ab335654..79fe83cf 100644 --- a/packages/production/CHANGELOG.md +++ b/packages/production/CHANGELOG.md @@ -1,18 +1,32 @@ -# 3.0.1 +# Change Log + +## 3.0.2 + +* Fixed NNBD issues +* Updated references to `angel3` framework +* Updated README + +## 3.0.1 + * Fixed static analysis warnings -# 3.0.0 +## 3.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 2.0.0 +## 2.0.0 + * Migrated to work with Dart SDK 2.12.x Non NNBD -# 1.0.0 +## 1.0.0 + * Support SSL/HTTP2. * Support muting the logger via `--quiet`. -# 1.0.0-alpha.1 +## 1.0.0-alpha.1 + * Import `framework/http`. -# 1.0.0-alpha -* Initial version. \ No newline at end of file +## 1.0.0-alpha + +* Initial version. diff --git a/packages/production/README.md b/packages/production/README.md index 425171bf..b34e2cb9 100644 --- a/packages/production/README.md +++ b/packages/production/README.md @@ -1,24 +1,24 @@ -# angel3_production -[![version](https://img.shields.io/badge/pub-v3.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_production) +# Angel3 Production Runner + +[![version](https://img.shields.io/badge/pub-v3.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_production) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/production/LICENSE) -Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel. +Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3 framework. -![Screenshot](screenshot.png) +![Screenshot](angel3-screenshot.png) -This will become the de-facto way to run Angel applications in deployed environments, as it -takes care of inter-isolate communication, respawning dead processes, and other housekeeping for you automatically. +This will become the de-facto way to run Angel3 applications in deployed environments, as it takes care of inter-isolate communication, respawning dead processes, and other housekeeping for you automatically. Most users will want to use the `Runner` class. ## `Runner` + `Runner` is a utility, powered by `package:args`, that is intended to be the entry point of your application. -Instantiate it as follows, and your file will become a command-line executable that spawns multiple instances of your -application: +Instantiate it as follows, and your file will become a command-line executable that spawns multiple instances of your application: ```dart import 'dart:async'; @@ -39,21 +39,18 @@ Future configureServer(Angel app) async { } ``` -`Runner` will automatically re-spawn crashed instances, unless `--no-respawn` is passed. This can prevent -your server from entirely going down at the first error, and adds a layer of fault tolerance to your -infrastructure. +`Runner` will automatically re-spawn crashed instances, unless `--no-respawn` is passed. This can prevent your server from entirely going down at the first error, and adds a layer of fault tolerance to your infrastructure. -When combined with `systemd`, deploying Angel applications on Linux can be very simple. +When combined with `systemd`, deploying Angel3 applications on Linux can be very simple. ## Message Passing + The `Runner` class uses [`package:angel3_pub_sub`](https://github.com/dukefirehawk/angel/tree/angel3/packages/pub_sub) to coordinate message passing between isolates. -When one isolate sends a message, all other isolates will -receive the same message, except for the isolate that sent it. +When one isolate sends a message, all other isolates will receive the same message, except for the isolate that sent it. -It is injected into your application's `Container` as -`pub_sub.Client`, so you can use it as follows: +It is injected into your application's `Container` as `pub_sub.Client`, so you can use it as follows: ```dart // Use the injected `pub_sub.Client` to send messages. @@ -71,9 +68,8 @@ onGreetingChanged ``` ## Run-time Metadata -At run-time, you may want to know information about the currently-running instance, -for example, which number instance. For this, the `InstanceInfo` class is injected -into each instance: + +At run-time, you may want to know information about the currently-running instance, for example, which number instance. For this, the `InstanceInfo` class is injected into each instance: ```dart var instanceInfo = app.container.make(); @@ -81,19 +77,20 @@ print('This is instance #${instanceInfo.id}'); ``` ## Command-line Options + The `Runner` class supplies options like the following: -``` -Prod-MacBook-Air:production appuser$ dart example/main.dart --help -____________ ________________________ -___ |__ | / /_ ____/__ ____/__ / -__ /| |_ |/ /_ / __ __ __/ __ / -_ ___ | /| / / /_/ / _ /___ _ /___ -/_/ |_/_/ |_/ ____/ /_____/ /_____/ +```bash +appuser$ dart example/main.dart --help + _ _ _ ____ _____ _ _____ + / \ | \ | |/ ___| ____| | |___ / + / _ \ | \| | | _| _| | | |_ \ + / ___ \| |\ | |_| | |___| |___ ___) | + /_/ \_\_| \_|\____|_____|_____|____/ A batteries-included, full-featured, full-stack framework in Dart. -https://angel-dart.github.io +https://angel3-framework.web.app Options: -h, --help Print this help information. @@ -117,4 +114,4 @@ Options: --certificate-password The PEM certificate file password. --key-file The PEM key file to read. --key-password The PEM key file password. -``` \ No newline at end of file +``` diff --git a/packages/production/angel3-screenshot.png b/packages/production/angel3-screenshot.png new file mode 100644 index 00000000..29d7d914 Binary files /dev/null and b/packages/production/angel3-screenshot.png differ diff --git a/packages/production/example/main.dart b/packages/production/example/main.dart index 9b1ba7e5..7e50928b 100644 --- a/packages/production/example/main.dart +++ b/packages/production/example/main.dart @@ -8,15 +8,15 @@ void main(List args) => Runner('example', configureServer).run(args); Future configureServer(Angel app) async { // Use the injected `pub_sub.Client` to send messages. - var client = app.container!.make()!; - String? greeting = 'Hello! This is the default greeting.'; + var client = app.container?.make(); + var greeting = 'Hello! This is the default greeting.'; // We can listen for an event to perform some behavior. // // Here, we use message passing to synchronize some common state. - var onGreetingChanged = await client.subscribe('greeting_changed'); + var onGreetingChanged = await client?.subscribe('greeting_changed'); onGreetingChanged - .cast() + ?.cast() .listen((newGreeting) => greeting = newGreeting); // Add some routes... @@ -32,8 +32,8 @@ Future configureServer(Angel app) async { // This route will push a new value for `greeting`. app.get('/change_greeting/:newGreeting', (req, res) { - greeting = req.params['newGreeting'] as String?; - client.publish('greeting_changed', greeting); + greeting = (req.params['newGreeting'] as String? ?? ''); + client?.publish('greeting_changed', greeting); return 'Changed greeting -> $greeting'; }); diff --git a/packages/production/lib/src/runner.dart b/packages/production/lib/src/runner.dart index e66392db..be5038df 100644 --- a/packages/production/lib/src/runner.dart +++ b/packages/production/lib/src/runner.dart @@ -26,7 +26,26 @@ class Runner { Runner(this.name, this.configureServer, {this.reflector = const EmptyReflector()}); + static const String asciiArt2 = ''' + + ___ _ ________________ _____ + / | / | / / ____/ ____/ / |__ / + / /| | / |/ / / __/ __/ / / /_ < + / ___ |/ /| / /_/ / /___/ /______/ / +/_/ |_/_/ |_/\\____/_____/_____/____/ + +'''; + static const String asciiArt = ''' + + _ _ _ ____ _____ _ _____ + / \\ | \\ | |/ ___| ____| | |___ / + / _ \\ | \\| | | _| _| | | |_ \\ + / ___ \\| |\\ | |_| | |___| |___ ___) | + /_/ \\_\\_| \\_|\\____|_____|_____|____/ +'''; + + static const String asciiArtOld = ''' ____________ ________________________ ___ |__ | / /_ ____/__ ____/__ / __ /| |_ |/ /_ / __ __ __/ __ / @@ -139,7 +158,7 @@ _ ___ | /| / / /_/ / _ /___ _ /___ /// Starts a number of isolates, running identical instances of an Angel application. Future run(List args) async { - late pub_sub.Server server; + pub_sub.Server? server; try { var argResults = RunnerOptions.argParser.parse(args); @@ -153,11 +172,11 @@ _ ___ | /| / / /_/ / _ /___ _ /___ } } - print(darkGray.wrap(asciiArt.trim() + + print(darkGray.wrap(asciiArt + '\n\n' + 'A batteries-included, full-featured, full-stack framework in Dart.' + '\n\n' + - 'https://angel-dart.github.io\n')); + 'https://angel3-framework.web.app\n')); if (argResults['help'] == true) { stdout..writeln('Options:')..writeln(RunnerOptions.argParser.usage); @@ -191,7 +210,7 @@ _ ___ | /| / / /_/ / _ /___ _ /___ ..writeln(red.wrap(st.toString())); exitCode = 1; } finally { - await server.close(); + await server?.close(); } } diff --git a/packages/production/pubspec.yaml b/packages/production/pubspec.yaml index 931c660a..3c8f0030 100644 --- a/packages/production/pubspec.yaml +++ b/packages/production/pubspec.yaml @@ -1,7 +1,8 @@ name: angel3_production -version: 3.0.1 -description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel. -homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/production +version: 3.0.2 +description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3. +homepage: https://angel3-framework.web.app +repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/production environment: sdk: '>=2.12.0 <3.0.0' dependencies: