Fixed deprecated warnings

This commit is contained in:
thomashii@dukefirehawk.com 2022-09-19 00:58:28 +08:00
parent 41167e01bd
commit 9a5201b6f0
23 changed files with 75 additions and 61 deletions

View file

@ -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;
});
}

8
doc/README.md Normal file
View file

@ -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.

View file

@ -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
lints: ^2.0.0

View file

@ -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
lints: ^2.0.0

View file

@ -4,7 +4,7 @@ import 'package:http/http.dart' as http;
Future<void> 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<void> fortunes(var message) async {
Future<void> 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<void> plaintext(var message) async {
Future<void> 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<void> json(var message) async {
Future<void> 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<void> dbUpdate(var message) async {
Future<void> 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<void> dbSingleQuery(var message) async {
Future<void> 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<void> 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));

View file

@ -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
lints: ^2.0.0

View file

@ -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

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.1
* Fixed `BytesBuilder` warnings
## 7.0.0
* Require Dart >= 2.17

View file

@ -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.

View file

@ -292,7 +292,7 @@ abstract class Driver<
ResponseContext res,
{bool ignoreFinalizers = false}) {
//app.logger.fine("Calling SendResponse");
Future<void> _cleanup(_) {
Future<void> cleanup(_) {
if (!app.environment.isProduction && req.container!.has<Stopwatch>()) {
var sw = req.container!.make<Stopwatch>();
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);
});
}

View file

@ -31,7 +31,7 @@ class HostnameRouter {
HostnameRouter(
{Map<Pattern, Angel> apps = const {},
Map<Pattern, FutureOr<Angel> Function()> creators = const {}}) {
Map<Pattern, V> _parseMap<V>(Map<Pattern, V> map) {
Map<Pattern, V> parseMap<V>(Map<Pattern, V> 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);

View file

@ -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';

View file

@ -233,10 +233,10 @@ abstract class ResponseContext<RawResponse>
/// Redirects to the given named [Route].
Future<void> 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<RawResponse>
return null;
}
var matched = _findRoute(app!);
var matched = findRoute(app!);
if (matched != null) {
await redirect(

View file

@ -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';

View file

@ -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';

View file

@ -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

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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 {

View file

@ -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

View file

@ -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');

View file

@ -90,7 +90,7 @@ class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
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<HasCar, Map> {
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));
}