From 5bfc268884fcabb61a0dab01de58c356e4535668 Mon Sep 17 00:00:00 2001 From: thomashii Date: Fri, 20 Aug 2021 12:59:02 +0800 Subject: [PATCH] Updated sync --- .../framework/lib/src/core/injection.dart | 4 +-- .../framework/test/http2/adapter_test.dart | 6 ++-- packages/sync/CHANGELOG.md | 15 ++++++-- packages/sync/README.md | 27 ++++++++------- packages/sync/example/main.dart | 16 ++++----- .../lib/{angel_sync.dart => angel3_sync.dart} | 4 +-- packages/sync/pubspec.yaml | 34 +++++-------------- packages/sync/test/all_test.dart | 16 ++++----- packages/test/lib/src/client.dart | 2 +- 9 files changed, 60 insertions(+), 64 deletions(-) rename packages/sync/lib/{angel_sync.dart => angel3_sync.dart} (92%) diff --git a/packages/framework/lib/src/core/injection.dart b/packages/framework/lib/src/core/injection.dart index fce2a249..8e65511a 100644 --- a/packages/framework/lib/src/core/injection.dart +++ b/packages/framework/lib/src/core/injection.dart @@ -23,8 +23,8 @@ RequestHandler ioc(Function handler, {Iterable optional = const []}) { }; } -resolveInjection(requirement, InjectionRequest injection, RequestContext req, - ResponseContext res, bool throwOnUnresolved, +Future resolveInjection(requirement, InjectionRequest injection, + RequestContext req, ResponseContext res, bool throwOnUnresolved, [Container? container]) async { var propFromApp; container ??= req.container ?? res.app!.container; diff --git a/packages/framework/test/http2/adapter_test.dart b/packages/framework/test/http2/adapter_test.dart index 595cf5e1..f727a6b7 100644 --- a/packages/framework/test/http2/adapter_test.dart +++ b/packages/framework/test/http2/adapter_test.dart @@ -65,9 +65,9 @@ void main() { app.post('/upload', (req, res) async { await req.parseBody(); var body = req.bodyAsMap; - List files = req.uploadedFiles ?? []; + var files = req.uploadedFiles ?? []; - UploadedFile file = files.firstWhereOrNull((f) => f.name == 'file')!; + var file = files.firstWhereOrNull((f) => f.name == 'file')!; return [ await file.data.map((l) => l.length).reduce((a, b) => a + b), file.contentType.mimeType, @@ -106,7 +106,7 @@ void main() { http2 = AngelHttp2(app, ctx, allowHttp1: true); - SecureServerSocket server = await http2.startServer(); + var server = await http2.startServer(); serverRoot = Uri.parse('https://127.0.0.1:${server.port}'); }); diff --git a/packages/sync/CHANGELOG.md b/packages/sync/CHANGELOG.md index 7e1c06f6..c2a1dcd5 100644 --- a/packages/sync/CHANGELOG.md +++ b/packages/sync/CHANGELOG.md @@ -1,6 +1,15 @@ -# 3.0.0 +# Change Log + +## 4.0.0 + +* Updated to use `angel3` packages +* Published with `angel3` prefix + +## 3.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 2.0.0 +## 2.0.0 + * Dart 2 + Angel 2 updates. -* Extend `StreamChannel`, instead of the defunct `WebSocketSynchronizer`. \ No newline at end of file +* Extend `StreamChannel`, instead of the defunct `WebSocketSynchronizer`. diff --git a/packages/sync/README.md b/packages/sync/README.md index 83ad914b..1f46dbca 100644 --- a/packages/sync/README.md +++ b/packages/sync/README.md @@ -1,21 +1,24 @@ -# sync -[![Pub](https://img.shields.io/pub/v/angel_sync.svg)](https://pub.dartlang.org/packages/angel_sync) -[![build status](https://travis-ci.org/angel-dart/sync.svg)](https://travis-ci.org/angel-dart/sync) +# Angel3 Sync -Easily synchronize and scale WebSockets using package:pub_sub. +[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_sync) +[![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) -# Usage -This package exposes `PubSubSynchronizationChannel`, which -can simply be dropped into any `AngelWebSocket` constructor. +[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/sync/LICENSE) -Once you've set that up, instances of your application will -automatically fire events in-sync. That's all you have to do +Easily synchronize and scale WebSockets using package:angel3_pub_sub. + +## Usage + +This package exposes `PubSubSynchronizationChannel`, which can simply be dropped into any `AngelWebSocket` constructor. + +Once you've set that up, instances of your application will automatically fire events in-sync. That's all you have to do to scale a real-time application with Angel! ```dart -await app.configure(new AngelWebSocket( +await app.configure(AngelWebSocket( synchronizationChannel: new PubSubSynchronizationChannel( - new pub_sub.IsolateClient('', adapter.receivePort.sendPort), + pub_sub.IsolateClient('', adapter.receivePort.sendPort), ), )); -``` \ No newline at end of file +``` diff --git a/packages/sync/example/main.dart b/packages/sync/example/main.dart index 264abfff..f654f10c 100644 --- a/packages/sync/example/main.dart +++ b/packages/sync/example/main.dart @@ -1,12 +1,12 @@ import 'dart:isolate'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_sync/angel_sync.dart'; -import 'package:angel_test/angel_test.dart'; -import 'package:angel_websocket/io.dart' as client; -import 'package:angel_websocket/server.dart'; -import 'package:pub_sub/isolate.dart' as pub_sub; -import 'package:pub_sub/pub_sub.dart' as pub_sub; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; +import 'package:angel3_sync/angel3_sync.dart'; +import 'package:angel3_test/angel3_test.dart'; +import 'package:angel3_websocket/io.dart' as client; +import 'package:angel3_websocket/server.dart'; +import 'package:angel3_pub_sub/isolate.dart' as pub_sub; +import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; import 'package:test/test.dart'; void main() { diff --git a/packages/sync/lib/angel_sync.dart b/packages/sync/lib/angel3_sync.dart similarity index 92% rename from packages/sync/lib/angel_sync.dart rename to packages/sync/lib/angel3_sync.dart index ce9df468..6c463bd9 100644 --- a/packages/sync/lib/angel_sync.dart +++ b/packages/sync/lib/angel3_sync.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:angel_websocket/angel_websocket.dart'; -import 'package:pub_sub/pub_sub.dart' as pub_sub; +import 'package:angel3_websocket/angel3_websocket.dart'; +import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; import 'package:stream_channel/stream_channel.dart'; /// Synchronizes WebSockets using `package:pub_sub`. diff --git a/packages/sync/pubspec.yaml b/packages/sync/pubspec.yaml index 71a1b908..e18fc0fe 100644 --- a/packages/sync/pubspec.yaml +++ b/packages/sync/pubspec.yaml @@ -1,32 +1,16 @@ -name: angel_sync -version: 3.0.0 -description: Easily synchronize and scale WebSockets using package:pub_sub. -homepage: https://github.com/angel-dart/sync -publish_to: none +name: angel3_sync +version: 4.0.0 +description: Easily synchronize and scale WebSockets using package:angel3_pub_sub for Angel3. +homepage: https://angel3-framework.web.app/ +repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/sync environment: sdk: '>=2.12.0 <3.0.0' dependencies: - angel_framework: #^2.0.0-alpha - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - angel_websocket: #^2.0.0-alpha - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/websocket - pub_sub: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/pub_sub + angel3_framework: ^4.1.0 + angel3_websocket: ^4.0.0 + angel3_pub_sub: ^3.0.0 stream_channel: ^2.1.0 dev_dependencies: - angel_test: #^2.0.0-alpha - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/test + angel3_test: ^4.0.0 test: ^1.17.8 pedantic: ^1.11.1 \ No newline at end of file diff --git a/packages/sync/test/all_test.dart b/packages/sync/test/all_test.dart index c9f0ac9d..4f628ce4 100644 --- a/packages/sync/test/all_test.dart +++ b/packages/sync/test/all_test.dart @@ -1,12 +1,12 @@ import 'dart:isolate'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_sync/angel_sync.dart'; -import 'package:angel_test/angel_test.dart'; -import 'package:angel_websocket/io.dart' as client; -import 'package:angel_websocket/server.dart'; -import 'package:pub_sub/isolate.dart' as pub_sub; -import 'package:pub_sub/pub_sub.dart' as pub_sub; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; +import 'package:angel3_sync/angel3_sync.dart'; +import 'package:angel3_test/angel3_test.dart'; +import 'package:angel3_websocket/io.dart' as client; +import 'package:angel3_websocket/server.dart'; +import 'package:angel3_pub_sub/isolate.dart' as pub_sub; +import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; import 'package:test/test.dart'; void main() { diff --git a/packages/test/lib/src/client.dart b/packages/test/lib/src/client.dart index 189801f4..71bb569f 100644 --- a/packages/test/lib/src/client.dart +++ b/packages/test/lib/src/client.dart @@ -69,7 +69,7 @@ class TestClient extends client.BaseAngelClient { @override Future close() { - this.client!.close(); + this.client.close(); return server.close(); }