Remove dep on package:pool

This commit is contained in:
Tobe O 2018-08-20 15:46:12 -04:00
parent 8739dbe4f7
commit b95f6b26e2
3 changed files with 3 additions and 22 deletions

View file

@ -30,4 +30,5 @@ replaced with `parseBody`, `parseUploadedFiles`, and `parseRawRequestBuffer`, re
* Removed the synchronous equivalents of the above methods (`body`, `files`, and `originalBuffer`),
as well as `query`.
* Removed `Angel.injections` and `RequestContext.injections`.
* Removed `Angel.inject`.
* Removed `Angel.inject`.
* Removed a dependency on `package:pool`, which also meant removing `AngelHttp.throttle`.

View file

@ -11,7 +11,6 @@ import 'dart:io'
import 'package:angel_http_exception/angel_http_exception.dart';
import 'package:angel_route/angel_route.dart';
import 'package:combinator/combinator.dart';
import 'package:pool/pool.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:tuple/tuple.dart';
import 'http_request_context.dart';
@ -29,8 +28,6 @@ class AngelHttp {
Future<HttpServer> Function(dynamic, int) _serverGenerator = HttpServer.bind;
StreamSubscription<HttpRequest> _sub;
Pool _pool;
AngelHttp(this.app, {this.useZone: true});
/// The function used to bind this instance to an HTTP server.
@ -323,10 +320,6 @@ class AngelHttp {
..add(outputBuffer);
return request.response.close().then((_) {
if (req.injections.containsKey(PoolResource)) {
req.injections[PoolResource].release();
}
if (!app.isProduction && app.logger != null) {
var sw = req.grab<Stopwatch>(Stopwatch);
@ -343,11 +336,7 @@ class AngelHttp {
Future<HttpRequestContext> createRequestContext(HttpRequest request) {
var path = request.uri.path.replaceAll(_straySlashes, '');
if (path.length == 0) path = '/';
return HttpRequestContext.from(request, app, path).then((req) {
if (_pool != null) req.inject(PoolResource, _pool.request());
if (app.injections.isNotEmpty) app.injections.forEach(req.inject);
return req;
});
return HttpRequestContext.from(request, app, path);
}
Future<ResponseContext> createResponseContext(HttpResponse response,
@ -356,12 +345,4 @@ class AngelHttp {
response, app, correspondingRequest as HttpRequestContext)
..serializer = (app.serializer ?? json.encode)
..encoders.addAll(app.encoders ?? {}));
/// Limits the maximum number of requests to be handled concurrently by this instance.
///
/// You can optionally provide a [timeout] to limit the amount of time a request can be
/// handled before.
void throttle(int maxConcurrentRequests, {Duration timeout}) {
_pool = new Pool(maxConcurrentRequests, timeout: timeout);
}
}

View file

@ -27,7 +27,6 @@ dependencies:
meta: ^1.0.0
mime: ^0.9.3
path: ^1.0.0
pool: ^1.0.0
stack_trace: ^1.0.0
tuple: ^1.0.0
dev_dependencies: