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

@ -31,3 +31,4 @@ replaced with `parseBody`, `parseUploadedFiles`, and `parseRawRequestBuffer`, re
as well as `query`. as well as `query`.
* Removed `Angel.injections` and `RequestContext.injections`. * 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_http_exception/angel_http_exception.dart';
import 'package:angel_route/angel_route.dart'; import 'package:angel_route/angel_route.dart';
import 'package:combinator/combinator.dart'; import 'package:combinator/combinator.dart';
import 'package:pool/pool.dart';
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import 'http_request_context.dart'; import 'http_request_context.dart';
@ -29,8 +28,6 @@ class AngelHttp {
Future<HttpServer> Function(dynamic, int) _serverGenerator = HttpServer.bind; Future<HttpServer> Function(dynamic, int) _serverGenerator = HttpServer.bind;
StreamSubscription<HttpRequest> _sub; StreamSubscription<HttpRequest> _sub;
Pool _pool;
AngelHttp(this.app, {this.useZone: true}); AngelHttp(this.app, {this.useZone: true});
/// The function used to bind this instance to an HTTP server. /// The function used to bind this instance to an HTTP server.
@ -323,10 +320,6 @@ class AngelHttp {
..add(outputBuffer); ..add(outputBuffer);
return request.response.close().then((_) { return request.response.close().then((_) {
if (req.injections.containsKey(PoolResource)) {
req.injections[PoolResource].release();
}
if (!app.isProduction && app.logger != null) { if (!app.isProduction && app.logger != null) {
var sw = req.grab<Stopwatch>(Stopwatch); var sw = req.grab<Stopwatch>(Stopwatch);
@ -343,11 +336,7 @@ class AngelHttp {
Future<HttpRequestContext> createRequestContext(HttpRequest request) { Future<HttpRequestContext> createRequestContext(HttpRequest request) {
var path = request.uri.path.replaceAll(_straySlashes, ''); var path = request.uri.path.replaceAll(_straySlashes, '');
if (path.length == 0) path = '/'; if (path.length == 0) path = '/';
return HttpRequestContext.from(request, app, path).then((req) { return HttpRequestContext.from(request, app, path);
if (_pool != null) req.inject(PoolResource, _pool.request());
if (app.injections.isNotEmpty) app.injections.forEach(req.inject);
return req;
});
} }
Future<ResponseContext> createResponseContext(HttpResponse response, Future<ResponseContext> createResponseContext(HttpResponse response,
@ -356,12 +345,4 @@ class AngelHttp {
response, app, correspondingRequest as HttpRequestContext) response, app, correspondingRequest as HttpRequestContext)
..serializer = (app.serializer ?? json.encode) ..serializer = (app.serializer ?? json.encode)
..encoders.addAll(app.encoders ?? {})); ..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 meta: ^1.0.0
mime: ^0.9.3 mime: ^0.9.3
path: ^1.0.0 path: ^1.0.0
pool: ^1.0.0
stack_trace: ^1.0.0 stack_trace: ^1.0.0
tuple: ^1.0.0 tuple: ^1.0.0
dev_dependencies: dev_dependencies: