Updated sync

This commit is contained in:
thomashii 2021-08-20 12:59:02 +08:00
parent ee3c087ef5
commit 5bfc268884
9 changed files with 60 additions and 64 deletions

View file

@ -23,8 +23,8 @@ RequestHandler ioc(Function handler, {Iterable<String> optional = const []}) {
}; };
} }
resolveInjection(requirement, InjectionRequest injection, RequestContext req, Future resolveInjection(requirement, InjectionRequest injection,
ResponseContext res, bool throwOnUnresolved, RequestContext req, ResponseContext res, bool throwOnUnresolved,
[Container? container]) async { [Container? container]) async {
var propFromApp; var propFromApp;
container ??= req.container ?? res.app!.container; container ??= req.container ?? res.app!.container;

View file

@ -65,9 +65,9 @@ void main() {
app.post('/upload', (req, res) async { app.post('/upload', (req, res) async {
await req.parseBody(); await req.parseBody();
var body = req.bodyAsMap; var body = req.bodyAsMap;
List<UploadedFile> files = req.uploadedFiles ?? []; var files = req.uploadedFiles ?? [];
UploadedFile file = files.firstWhereOrNull((f) => f.name == 'file')!; var file = files.firstWhereOrNull((f) => f.name == 'file')!;
return [ return [
await file.data.map((l) => l.length).reduce((a, b) => a + b), await file.data.map((l) => l.length).reduce((a, b) => a + b),
file.contentType.mimeType, file.contentType.mimeType,
@ -106,7 +106,7 @@ void main() {
http2 = AngelHttp2(app, ctx, allowHttp1: true); 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}'); serverRoot = Uri.parse('https://127.0.0.1:${server.port}');
}); });

View file

@ -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 * Migrated to support Dart SDK 2.12.x NNBD
# 2.0.0 ## 2.0.0
* Dart 2 + Angel 2 updates. * Dart 2 + Angel 2 updates.
* Extend `StreamChannel`, instead of the defunct `WebSocketSynchronizer`. * Extend `StreamChannel`, instead of the defunct `WebSocketSynchronizer`.

View file

@ -1,21 +1,24 @@
# sync # Angel3 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)
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 [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/sync/LICENSE)
This package exposes `PubSubSynchronizationChannel`, which
can simply be dropped into any `AngelWebSocket` constructor.
Once you've set that up, instances of your application will Easily synchronize and scale WebSockets using package:angel3_pub_sub.
automatically fire events in-sync. That's all you have to do
## 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! to scale a real-time application with Angel!
```dart ```dart
await app.configure(new AngelWebSocket( await app.configure(AngelWebSocket(
synchronizationChannel: new PubSubSynchronizationChannel( synchronizationChannel: new PubSubSynchronizationChannel(
new pub_sub.IsolateClient('<client-id>', adapter.receivePort.sendPort), pub_sub.IsolateClient('<client-id>', adapter.receivePort.sendPort),
), ),
)); ));
``` ```

View file

@ -1,12 +1,12 @@
import 'dart:isolate'; import 'dart:isolate';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel_framework/http.dart'; import 'package:angel3_framework/http.dart';
import 'package:angel_sync/angel_sync.dart'; import 'package:angel3_sync/angel3_sync.dart';
import 'package:angel_test/angel_test.dart'; import 'package:angel3_test/angel3_test.dart';
import 'package:angel_websocket/io.dart' as client; import 'package:angel3_websocket/io.dart' as client;
import 'package:angel_websocket/server.dart'; import 'package:angel3_websocket/server.dart';
import 'package:pub_sub/isolate.dart' as pub_sub; import 'package:angel3_pub_sub/isolate.dart' as pub_sub;
import 'package:pub_sub/pub_sub.dart' as pub_sub; import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub;
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {

View file

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:angel_websocket/angel_websocket.dart'; import 'package:angel3_websocket/angel3_websocket.dart';
import 'package:pub_sub/pub_sub.dart' as pub_sub; import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub;
import 'package:stream_channel/stream_channel.dart'; import 'package:stream_channel/stream_channel.dart';
/// Synchronizes WebSockets using `package:pub_sub`. /// Synchronizes WebSockets using `package:pub_sub`.

View file

@ -1,32 +1,16 @@
name: angel_sync name: angel3_sync
version: 3.0.0 version: 4.0.0
description: Easily synchronize and scale WebSockets using package:pub_sub. description: Easily synchronize and scale WebSockets using package:angel3_pub_sub for Angel3.
homepage: https://github.com/angel-dart/sync homepage: https://angel3-framework.web.app/
publish_to: none repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/sync
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
dependencies: dependencies:
angel_framework: #^2.0.0-alpha angel3_framework: ^4.1.0
git: angel3_websocket: ^4.0.0
url: https://github.com/dukefirehawk/angel.git angel3_pub_sub: ^3.0.0
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
stream_channel: ^2.1.0 stream_channel: ^2.1.0
dev_dependencies: dev_dependencies:
angel_test: #^2.0.0-alpha angel3_test: ^4.0.0
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/test
test: ^1.17.8 test: ^1.17.8
pedantic: ^1.11.1 pedantic: ^1.11.1

View file

@ -1,12 +1,12 @@
import 'dart:isolate'; import 'dart:isolate';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel_framework/http.dart'; import 'package:angel3_framework/http.dart';
import 'package:angel_sync/angel_sync.dart'; import 'package:angel3_sync/angel3_sync.dart';
import 'package:angel_test/angel_test.dart'; import 'package:angel3_test/angel3_test.dart';
import 'package:angel_websocket/io.dart' as client; import 'package:angel3_websocket/io.dart' as client;
import 'package:angel_websocket/server.dart'; import 'package:angel3_websocket/server.dart';
import 'package:pub_sub/isolate.dart' as pub_sub; import 'package:angel3_pub_sub/isolate.dart' as pub_sub;
import 'package:pub_sub/pub_sub.dart' as pub_sub; import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub;
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {

View file

@ -69,7 +69,7 @@ class TestClient extends client.BaseAngelClient {
@override @override
Future close() { Future close() {
this.client!.close(); this.client.close();
return server.close(); return server.close();
} }