diff --git a/archived_packages/poll/lib/angel_poll.dart b/archived_packages/poll/lib/angel_poll.dart index 095bc4a6..7c245258 100644 --- a/archived_packages/poll/lib/angel_poll.dart +++ b/archived_packages/poll/lib/angel_poll.dart @@ -109,7 +109,9 @@ class PollingService extends Service { @override Future close() async { _timer.cancel(); - _subs.forEach((s) => s.cancel()); + for (var s in _subs) { + s.cancel(); + } await _onIndexed.close(); await _onRead.close(); await _onCreated.close(); @@ -124,7 +126,7 @@ class PollingService extends Service { return inner.index().then((data) { //return asPaginated == true ? data['data'] : data; //return asPaginated == true ? data[0] : data; - return data!; + return data; }); } diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 00000000..f143af7e --- /dev/null +++ b/doc/README.md @@ -0,0 +1,8 @@ +# Performance Testing + +## WRT + + ```bash + wrk -t12 -c400 -d30s http://localhost:8080/query?queries=20 + ``` +This runs a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open. diff --git a/experiment/db/pubspec.yaml b/experiment/db/pubspec.yaml index 0815302f..40588c7f 100644 --- a/experiment/db/pubspec.yaml +++ b/experiment/db/pubspec.yaml @@ -3,7 +3,7 @@ version: 1.0.0 description: Angel3 performance testing tool publish_to: none environment: - sdk: '>=2.16.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' published_to: none dependencies: mysql1: ^0.20.0 @@ -11,4 +11,4 @@ dependencies: postgres: ^2.4.1 postgres_pool: ^2.1.3 dev_dependencies: - lints: ^1.0.0 \ No newline at end of file + lints: ^2.0.0 \ No newline at end of file diff --git a/experiment/logging/pubspec.yaml b/experiment/logging/pubspec.yaml index 0bfdd66a..2afc783a 100644 --- a/experiment/logging/pubspec.yaml +++ b/experiment/logging/pubspec.yaml @@ -3,9 +3,9 @@ version: 1.0.0 description: Angel3 performance testing tool publish_to: none environment: - sdk: '>=2.16.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' published_to: none dependencies: http: ^0.13.4 dev_dependencies: - lints: ^1.0.0 \ No newline at end of file + lints: ^2.0.0 \ No newline at end of file diff --git a/experiment/performance/bin/main.dart b/experiment/performance/bin/main.dart index 92891134..8a3a68cb 100644 --- a/experiment/performance/bin/main.dart +++ b/experiment/performance/bin/main.dart @@ -4,7 +4,7 @@ import 'package:http/http.dart' as http; Future fortunes(var message) async { var stopwatch = Stopwatch()..start(); - var url = Uri.http('localhost:3000', '/fortunes'); + var url = Uri.http('localhost:8080', '/fortunes'); var response = await http.get(url); print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms'); stopwatch.stop(); @@ -19,7 +19,7 @@ Future fortunes(var message) async { Future plaintext(var message) async { var stopwatch = Stopwatch()..start(); - var url = Uri.http('localhost:3000', '/plaintext'); + var url = Uri.http('localhost:8080', '/plaintext'); var response = await http.get(url); if (response.statusCode == 200) { print('Execution($message): ${response.body}.'); @@ -34,7 +34,7 @@ Future plaintext(var message) async { Future json(var message) async { var stopwatch = Stopwatch()..start(); - var url = Uri.http('localhost:3000', '/json'); + var url = Uri.http('localhost:8080', '/json'); var response = await http.get(url); print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms'); stopwatch.stop(); @@ -49,7 +49,7 @@ Future json(var message) async { Future dbUpdate(var message) async { var stopwatch = Stopwatch()..start(); - var url = Uri.http('localhost:3000', '/updates', {'queries': "5"}); + var url = Uri.http('localhost:8080', '/updates', {'queries': "5"}); var response = await http.get(url); print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms'); stopwatch.stop(); @@ -64,7 +64,7 @@ Future dbUpdate(var message) async { Future dbSingleQuery(var message) async { var stopwatch = Stopwatch()..start(); - var url = Uri.http('localhost:3000', '/db'); + var url = Uri.http('localhost:8080', '/db'); var response = await http.get(url); print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms'); stopwatch.stop(); @@ -79,7 +79,7 @@ Future dbSingleQuery(var message) async { Future dbMultipleQuery(var message) async { var stopwatch = Stopwatch()..start(); - var url = Uri.http('localhost:3000', '/query', {'queries': "5"}); + var url = Uri.http('localhost:8080', '/query', {'queries': "5"}); var response = await http.get(url); print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms'); stopwatch.stop(); @@ -92,10 +92,10 @@ Future dbMultipleQuery(var message) async { } void main() async { - var concurrency = 6000; + var concurrency = 2000; for (var i = 0; i < concurrency; i++) { - Isolate.spawn(plaintext, 'Instance_$i'); + Isolate.spawn(dbSingleQuery, 'Instance_$i'); } await Future.delayed(const Duration(seconds: 10)); diff --git a/experiment/performance/pubspec.yaml b/experiment/performance/pubspec.yaml index 0bfdd66a..2afc783a 100644 --- a/experiment/performance/pubspec.yaml +++ b/experiment/performance/pubspec.yaml @@ -3,9 +3,9 @@ version: 1.0.0 description: Angel3 performance testing tool publish_to: none environment: - sdk: '>=2.16.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' published_to: none dependencies: http: ^0.13.4 dev_dependencies: - lints: ^1.0.0 \ No newline at end of file + lints: ^2.0.0 \ No newline at end of file diff --git a/experiment/performance/tests/techempower.http b/experiment/performance/tests/techempower.http index 91b285c3..b6a46736 100644 --- a/experiment/performance/tests/techempower.http +++ b/experiment/performance/tests/techempower.http @@ -1,19 +1,19 @@ ### JSON Test -GET http://localhost:3000/json HTTP/1.1 +GET http://localhost:8080/json HTTP/1.1 ### Plaintext Test -GET http://localhost:3000/plaintext HTTP/1.1 +GET http://localhost:8080/plaintext HTTP/1.1 ### Fortunes Test -GET http://localhost:3000/fortunes HTTP/1.1 +GET http://localhost:8080/fortunes HTTP/1.1 ### Db Test -GET http://localhost:3000/db HTTP/1.1 +GET http://localhost:8080/db HTTP/1.1 ### Query test -GET http://localhost:3000/query?queries=20 HTTP/1.1 +GET http://localhost:8080/query?queries=20 HTTP/1.1 ### Update Test -GET http://localhost:3000/updates?queries=20 HTTP/1.1 +GET http://localhost:8080/updates?queries=20 HTTP/1.1 diff --git a/packages/framework/CHANGELOG.md b/packages/framework/CHANGELOG.md index 0434db9c..ba6d202d 100644 --- a/packages/framework/CHANGELOG.md +++ b/packages/framework/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.1 + +* Fixed `BytesBuilder` warnings + ## 7.0.0 * Require Dart >= 2.17 diff --git a/packages/framework/README.md b/packages/framework/README.md index 354b6681..14d9593c 100644 --- a/packages/framework/README.md +++ b/packages/framework/README.md @@ -19,9 +19,10 @@ This package is the core package of [Angel3](https://github.com/dukefirehawk/ang 1. Download and install [Dart](https://dart.dev/get-dart) 2. Clone one of the following starter projects: - * [Angel3 Basic Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-basic) - * [Angel3 ORM Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-orm) - * [Angel3 Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-graphql) + * [Angel3 Basic Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-basic) + * [Angel3 ORM Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm) + * [Angel3 ORM MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm-mysql) + * [Angel3 Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-graphql) 3. Run the project in development mode (*hot-reloaded* is enabled on file changes). @@ -70,3 +71,7 @@ This package is the core package of [Angel3](https://github.com/dukefirehawk/ang ### Migrating from Angel to Angel3 Check out [Migrating to Angel3](https://angel3-docs.dukefirehawk.com/migration/angel-2.x.x-to-angel3/migration-guide-3) + +## Donation & Support + +If you like this project and interested in supporting its development, you can make a donation via [paypal](https://paypal.me/dukefirehawk?country.x=MY&locale.x=en_US) service. diff --git a/packages/framework/lib/src/core/driver.dart b/packages/framework/lib/src/core/driver.dart index 74289c6e..fb328f4e 100644 --- a/packages/framework/lib/src/core/driver.dart +++ b/packages/framework/lib/src/core/driver.dart @@ -292,7 +292,7 @@ abstract class Driver< ResponseContext res, {bool ignoreFinalizers = false}) { //app.logger.fine("Calling SendResponse"); - Future _cleanup(_) { + Future cleanup(_) { if (!app.environment.isProduction && req.container!.has()) { var sw = req.container!.make(); app.logger.fine( @@ -310,7 +310,7 @@ abstract class Driver< if (!res.isBuffered) { //if (res.isOpen) { - return res.close().then(_cleanup); + return res.close().then(cleanup); //} //return Future.value(); } @@ -372,7 +372,7 @@ abstract class Driver< setStatusCode(response, res.statusCode); addCookies(response, res.cookies); writeToResponse(response, outputBuffer); - return closeResponse(response).then(_cleanup); + return closeResponse(response).then(cleanup); }); } diff --git a/packages/framework/lib/src/core/hostname_router.dart b/packages/framework/lib/src/core/hostname_router.dart index 09c4615e..a1c571e5 100644 --- a/packages/framework/lib/src/core/hostname_router.dart +++ b/packages/framework/lib/src/core/hostname_router.dart @@ -31,7 +31,7 @@ class HostnameRouter { HostnameRouter( {Map apps = const {}, Map Function()> creators = const {}}) { - Map _parseMap(Map map) { + Map parseMap(Map map) { return map.map((p, c) { Pattern pp; @@ -45,8 +45,8 @@ class HostnameRouter { }); } - apps = _parseMap(apps); - creators = _parseMap(creators); + apps = parseMap(apps); + creators = parseMap(creators); var patterns = apps.keys.followedBy(creators.keys).toSet().toList(); _apps.addAll(apps); _creators.addAll(creators); diff --git a/packages/framework/lib/src/core/request_context.dart b/packages/framework/lib/src/core/request_context.dart index 520df530..19499af3 100644 --- a/packages/framework/lib/src/core/request_context.dart +++ b/packages/framework/lib/src/core/request_context.dart @@ -2,14 +2,9 @@ library angel_framework.http.request_context; import 'dart:async'; import 'dart:convert'; +import 'dart:typed_data' show BytesBuilder; import 'dart:io' - show - BytesBuilder, - Cookie, - HeaderValue, - HttpHeaders, - HttpSession, - InternetAddress; + show Cookie, HeaderValue, HttpHeaders, HttpSession, InternetAddress; import 'package:angel3_container/angel3_container.dart'; import 'package:http_parser/http_parser.dart'; diff --git a/packages/framework/lib/src/core/response_context.dart b/packages/framework/lib/src/core/response_context.dart index 6fbdfd95..317c07fd 100644 --- a/packages/framework/lib/src/core/response_context.dart +++ b/packages/framework/lib/src/core/response_context.dart @@ -233,10 +233,10 @@ abstract class ResponseContext /// Redirects to the given named [Route]. Future redirectTo(String name, [Map? params, int? code]) async { if (!isOpen) throw closed(); - Route? _findRoute(Router r) { + Route? findRoute(Router r) { for (var route in r.routes) { if (route is SymlinkRoute) { - final m = _findRoute(route.router); + final m = findRoute(route.router); if (m != null) return m; } else if (route.name == name) { @@ -247,7 +247,7 @@ abstract class ResponseContext return null; } - var matched = _findRoute(app!); + var matched = findRoute(app!); if (matched != null) { await redirect( diff --git a/packages/framework/lib/src/http/http_response_context.dart b/packages/framework/lib/src/http/http_response_context.dart index b310061d..7c40883b 100644 --- a/packages/framework/lib/src/http/http_response_context.dart +++ b/packages/framework/lib/src/http/http_response_context.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; - +import 'dart:io' hide BytesBuilder; +import 'dart:typed_data' show BytesBuilder; import 'package:http_parser/http_parser.dart'; import '../core/core.dart'; diff --git a/packages/framework/lib/src/http2/http2_response_context.dart b/packages/framework/lib/src/http2/http2_response_context.dart index 28ec3420..dccb3b38 100644 --- a/packages/framework/lib/src/http2/http2_response_context.dart +++ b/packages/framework/lib/src/http2/http2_response_context.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'dart:io' hide BytesBuilder; +import 'dart:typed_data' show BytesBuilder; import 'package:angel3_framework/angel3_framework.dart' hide Header; import 'package:http2/transport.dart'; import 'http2_request_context.dart'; diff --git a/packages/framework/pubspec.yaml b/packages/framework/pubspec.yaml index 2b6c7e86..9b31bb6c 100644 --- a/packages/framework/pubspec.yaml +++ b/packages/framework/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_framework -version: 7.0.0 +version: 7.0.1 description: A high-powered HTTP server extensible framework with dependency injection, routing and much more. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework diff --git a/packages/framework/test/encoders_buffer_test.dart b/packages/framework/test/encoders_buffer_test.dart index 7b1e3a2b..b98b8892 100644 --- a/packages/framework/test/encoders_buffer_test.dart +++ b/packages/framework/test/encoders_buffer_test.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'dart:io' hide BytesBuilder; +import 'dart:typed_data' show BytesBuilder; import 'package:angel3_container/mirrors.dart'; import 'package:angel3_framework/angel3_framework.dart'; diff --git a/packages/framework/test/http2/adapter_test.dart b/packages/framework/test/http2/adapter_test.dart index f727a6b7..3d10cab4 100644 --- a/packages/framework/test/http2/adapter_test.dart +++ b/packages/framework/test/http2/adapter_test.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'dart:io' hide BytesBuilder; +import 'dart:typed_data' show BytesBuilder; import 'package:angel3_container/mirrors.dart'; import 'package:angel3_framework/angel3_framework.dart' hide Header; import 'package:angel3_framework/http2.dart'; diff --git a/packages/framework/test/http2/http2_client.dart b/packages/framework/test/http2/http2_client.dart index cd412a9e..37d33dd1 100644 --- a/packages/framework/test/http2/http2_client.dart +++ b/packages/framework/test/http2/http2_client.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; +import 'dart:io' hide BytesBuilder; +import 'dart:typed_data' show BytesBuilder; import 'package:http/http.dart'; import 'package:http2/transport.dart'; diff --git a/packages/framework/test/streaming_test.dart b/packages/framework/test/streaming_test.dart index b31a4ab6..d416fb93 100644 --- a/packages/framework/test/streaming_test.dart +++ b/packages/framework/test/streaming_test.dart @@ -76,7 +76,7 @@ void main() { tearDown(() => http.close()); - void _expectHelloBye(String path) async { + void expectHelloBye(String path) async { var rq = MockHttpRequest('GET', Uri.parse(path)); await (rq.close()); await http.handleRequest(rq); @@ -84,9 +84,9 @@ void main() { expect(body, 'Hello, world!bye'); } - test('write after addStream', () => _expectHelloBye('/write')); + test('write after addStream', () => expectHelloBye('/write')); - test('multiple addStream', () => _expectHelloBye('/multiple')); + test('multiple addStream', () => expectHelloBye('/multiple')); test('cannot write after close', () async { try { diff --git a/packages/hot/README.md b/packages/hot/README.md index b6919173..31e1bce6 100644 --- a/packages/hot/README.md +++ b/packages/hot/README.md @@ -7,8 +7,7 @@ ![Screenshot of terminal](screenshots/angel3-screenshot.png) -Supports *hot reloading* of Angel3 servers on file changes. This is faster and more reliable than merely reactively restarting a `Process`. -This package only works with the [Angel3 framework](https://pub.dev/packages/angel3_framework). +Supports *hot reloading* of Angel3 servers on file changes. This is faster and more reliable than merely reactively restarting a `Process`. This package only works with the [Angel3 framework](https://pub.dev/packages/angel3_framework). **Not recommended to use in production, unless you are specifically intending for a "hot code push" in production..** @@ -18,8 +17,8 @@ In your `pubspec.yaml`: ```yaml dependencies: - angel3_framework: ^6.0.0 - angel3_hot: ^6.0.0 + angel3_framework: ^7.0.0 + angel3_hot: ^7.0.0 ``` ## Usage diff --git a/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart b/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart index 2949eb7a..07129448 100644 --- a/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart +++ b/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart @@ -95,9 +95,6 @@ class MySqlExecutor extends QueryExecutor { } } - //var params = substitutionValues.values.toList(); - //var params = []; - //logger.warning('Query: $query'); //logger.warning('Values: $substitutionValues'); //logger.warning('Returning Query: $returningQuery'); diff --git a/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart b/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart index 65f70b26..c31ca9b2 100644 --- a/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart @@ -90,7 +90,7 @@ class HasCarQuery extends Query { type: fields.contains('type') ? row[3] == null ? null - : CarType?.values[(row[3] as int)] + : CarType.values[(row[3] as int)] : null); return Optional.of(model); } @@ -145,7 +145,7 @@ class HasCarQueryValues extends MapQueryValues { set updatedAt(DateTime? value) => values['updated_at'] = value; CarType? get type { - return CarType?.values[(values['type'] as int)]; + return CarType.values[(values['type'] as int)]; } set type(CarType? value) => values['type'] = value?.index; @@ -259,7 +259,7 @@ class HasCarSerializer extends Codec { type: map['type'] is CarType? ? (map['type'] as CarType?) ?? CarType.sedan : (map['type'] is int - ? CarType?.values[map['type'] as int] + ? CarType.values[map['type'] as int] : CarType.sedan)); }