wu-wu / plack-middleware-throttle-lite Goto Github PK
View Code? Open in Web Editor NEWRequests throttling for Plack
Home Page: https://metacpan.org/release/Plack-Middleware-Throttle-Lite
Requests throttling for Plack
Home Page: https://metacpan.org/release/Plack-Middleware-Throttle-Lite
Hi. I found a bug in https://github.com/Wu-Wu/Plack-Middleware-Throttle-Lite/blob/master/lib/Plack/Middleware/Throttle/Lite/Backend/Abstract.pm#L73
This will always return 'req/hour' as there is no "unit" setup for each unit in $settings href in the function above.
Possible soultions are:
a) add the corresponding "unit" to each of the units hrefs in the settings, or
b) change the line in the beginning of the bug to something like:
my $unit = $self->units || 'req/hour';
This bug is kind of critical, because currently Throttle::Lite works properly only with req/hour limits for backends that rely on expires_in
When running with Gazelle (https://github.com/kazeburo/Gazelle) I get the following warning on each request:
Use of uninitialized value in join or string at /opt/plenv/versions/5.26.0/lib/perl5/site_perl/5.26.0/Plack/Middleware/Throttle/Lite.pm line 280.
This is the code in question:
# Requester's ID
sub requester_id {
my ($self, $env) = @_;
join ':' => 'throttle', $env->{REMOTE_ADDR}, ($env->{REMOTE_USER} || $self->defaults->{username});
}
I believe that $env->{REMOTE_ADDR} is not set by Gazelle, which may actually be a Gazelle issue.
I am running with Gazelle like this:
/opt/plenv/versions/5.26.0/bin/start_server \
--path /run/etd.sock \
-- \
/opt/plenv/versions/5.26.0/bin/plackup \
-s Gazelle \
--max-workers 5 \
--max-reqs-per-child 1000 \
--min-reqs-per-child 800 \
--app script/etd.psgi
The default HTTP::Server::PSGI server has no such warning.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.