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,
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;

View file

@ -65,9 +65,9 @@ void main() {
app.post('/upload', (req, res) async {
await req.parseBody();
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 [
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}');
});

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
# 2.0.0
## 2.0.0
* 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
[![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('<client-id>', adapter.receivePort.sendPort),
pub_sub.IsolateClient('<client-id>', adapter.receivePort.sendPort),
),
));
```
```

View file

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

View file

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

View file

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

View file

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

View file

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