Skip to content

Commit

Permalink
#59 extra checks
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 10, 2024
1 parent 4a9bd86 commit e2d33b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/fbe/middleware/quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ def initialize(app, loog: Loog::NULL, pause: 60, limit: 100, rate: 5)
super(app)
@requests = 0
@app = app
raise 'The "loog" cannot be nil' if loog.nil?
@loog = loog
raise 'The "pause" cannot be nil' if pause.nil?
raise 'The "pause" must be a positive integer' unless pause.positive?
@pause = pause
raise 'The "limit" cannot be nil' if limit.nil?
raise 'The "limit" must be a positive integer' unless limit.positive?
@limit = limit
raise 'The "rate" cannot be nil' if rate.nil?
raise 'The "rate" must be a positive integer' unless rate.positive?
@rate = rate
end

Expand Down
2 changes: 1 addition & 1 deletion test/fbe/middleware/test_quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def call(env)

def test_quota_middleware_pauses_when_quota_low
loog = Loog::NULL
pause = 0
pause = 1
app = FakeApp.new
middleware = Fbe::Middleware::Quota.new(app, loog:, pause:)
start_time = Time.now
Expand Down

0 comments on commit e2d33b4

Please sign in to comment.