Commit Graph

77 Commits (v2)

Author SHA1 Message Date
nickajacks1 1e55045a30
test(limiter): fix intermittent failures (#2716)
The limiter middleware unit tests are failing due to a race between the
storage garbage collector and the unit test itself. The sliding window
limiter tracks requests using memory storage. In several of the unit
tests, this storage expiry ends up being 4 seconds. The test waits for 4
seconds, then sends a request, expecting it to succeed. However, the
unit test occasionally wakes up before the storage GC kicks in. As an
effect of the very coarse timer (using seconds as units), the middleware
correctly rejects the request, causing the test to fail.

Update the sleep to 4.5 seconds. This will not slow down the execution
of the test suite, as these tests run in parallel with a separate 9
second long test.

I'm not 100% sure this solves the issue, and ideally we'd be able to
run tests without time.Sleep.
2023-11-10 11:33:10 +01:00
Jiun Lee fefc533834
🚀 Add Logger interface and fiberlog (#2499)
* add log for fiber

* replace log in fiber

* add Log use to adapt for log libraries

* Update app.go

Co-authored-by: Tomás Warynyca <41587659+tomaswarynyca@users.noreply.github.com>

* wip: add log docs

* add WithLogger use to print key and value

* remove CtxLogger and add WithContext use to bind Context

* fix errcheck

* fix errcheck

* update log.md

---------

Co-authored-by: Tomás Warynyca <41587659+tomaswarynyca@users.noreply.github.com>
2023-06-26 08:16:57 +02:00
Oleg b9e93ccd4a
Fix Sliding Window limiter when SkipSuccessfulRequests/SkipFailedRequests is used. (#2484)
* Fix Sliding Window limiter when SkipSuccessfulRequests/SkipFailedRequests is used.

* Add tests.

* Fix linter.

---------

Co-authored-by: Oleg Bakumenko <Bakumenko.Oleg@wb.ru>
2023-06-01 08:00:31 +02:00
RW 3a7dbd0b48
🚀 Consistent way of logging and fix middleware log format #2432 (#2444)
- change log patter
2023-05-01 18:52:30 +02:00
Kousik Mitra a59d9bac59
🚀 Consistent way of logging and fix middleware log format (#2432)
* 🚀 Replace fmt.Print* with log.Print* (#2402)

* 🚀 Fix middleware logging format (#2402)
2023-05-01 10:01:27 +02:00
Muhammed Efe Çetin 15e9235383
📝 docs: remove README.mds from middleware dirs 2023-03-06 16:42:35 +03:00
Caio Augusto 44fd1976e7
fix(docs): add missing comma (#2353)
fix: add missing comma

nothing too much but it's a fix :p
2023-03-05 23:26:06 +03:00
leonklingele ac4ce21d9c
🐛 Bug: Fix issues introduced in linting PR (#2319)
* internal: revert linting changes

Changes to the internal package should not have been made in 167a8b5e94.

* middleware/monitor: revert changes to exported field "ChartJSURL"

This is a breaking change introduced in 167a8b5e94.

* middleware/monitor: fix error checking

Fix the errorenous error checking introduced in 167a8b5e94.

* 🐛 Bug: Fix issues introduced in linting PR #2319

* 🐛 Bug: Fix issues introduced in linting PR #2319

* Bug: Fix issues introduced in linting PR #2319

---------

Co-authored-by: René Werner <rene@gofiber.io>
2023-02-02 15:57:40 +01:00
leonklingele 167a8b5e94
🚀 Feature: Add and apply more stricter golangci-lint linting rules (#2286)
* golangci-lint: add and apply more stricter linting rules

* github: drop security workflow now that we use gosec linter inside golangci-lint

* github: use official golangci-lint CI linter

* Add editorconfig and gitattributes file
2023-01-27 09:01:37 +01:00
M. Efe Çetin 5406560033
🧹 chore: make most tests parallel (#2299)
* 🧹 chore: make most tests parallel

* revert some tests

* revert some tests

* revert some tests
2023-01-15 23:21:37 +08:00
TwiN ad5250a6ff
📝docs(middleware): fix alignment in limiter example (#2283)
docs(middleware): Fix indentation in limiter example

Noticed a small formatting issue while going through the docs.
2023-01-05 12:32:28 +08:00
M. Efe Çetin 691d2e6ad5
🗑️ deprecate: go 1.14 & go 1.15 support deprecation (#2172)
* 🗑️ deprecate: go 1.14 & go 1.15 support deprecation
https://github.com/valyala/fasthttp/pull/1379

* fix tests
2022-10-26 11:51:50 +02:00
RW ce2d087394
Improve memory storage (#2162)
* improve memory storage code and performance

* improve memory storage code and performance

* improve memory storage code and performance

* improve memory storage code and performance

* improve memory storage code and performance

* improve memory storage code and performance
2022-10-19 16:22:42 +02:00
Vadim Gerasimenko c92a5056ae
🩹 Fix limiter middleware db connection (#1813)
* remove release() method

* Revert "remove release() method"

This reverts commit fdfc8da967.

* Rearrange mutexes in limiter_fixed.go

* refactor limiter_fixed.go

* Update limiter_fixed.go

Co-authored-by: RW <rene@gofiber.io>
2022-03-15 12:41:28 +01:00
Vadim Gerasimenko c5f11cc800
Fix comment relating to deprecated field (#1790) 2022-02-20 19:01:16 +03:00
Norbert Hauriel 569511eb78
📝 fix file names (#1747) (#1748) 2022-02-03 12:58:59 -05:00
Norbert Hauriel d85ae2bce3
Doc(limiter): clarify variable name 'expire' (#1742)
This clarifies the intent of variable 'expire' by renaming to
the more understandable 'resetInSec'. All mentions are renamed as well.
2022-02-03 09:26:25 +01:00
Gusted 7b7dcf29f7
♻️ Tidy up the codebase (#1613)
* run gofmt

* add t.Helper()

* Simplify assigns

* Simplify make operation

* Remove unused field in struct

* Fix typo

* Run gofumpt ./

* Consistent spacing

* len(...) can never be negative

* Use ReplaceAll

* Simplify operation

* Remove deadcode

* Fix typo

* Tidy up `} else { if ...`

* Fix AssertEqual

* Remove t.Helper() to fix go1.14.15
2021-11-05 08:00:03 +01:00
Gusted 36796ee7a1
fix: remove `Test_Limiter_Cheat` test (#1595) 2021-10-25 07:04:56 +02:00
Gusted e6feb36827
feat: add sliding window as option for limiter middleware (#1580)
- Add the options to use your own middleware(should be more modular over time).
- Add the Sliding window option(see #1247)
- A little bit better polished version of #1247.
2021-10-18 09:13:53 +02:00
Ali Eren Öztürk 9c37b4c1c5
Fix limit middleware skip options (#1568)
* fix limit middleware skip options

* fix limiter middleware remaining count

* used constant StatusBadRequest instead of int 400
2021-10-11 18:31:37 +02:00
Ali Eren Öztürk 2aef5f8e01
limiter middleware new options: SkipFailedRequests, SkipSuccessfulRequests (#1542) 2021-09-28 10:10:29 +02:00
sadfun 547bdb1c23
Change deprecated struct elements (#1335)
Duration and Store are deprecated, so we should show Expiration and Storage in example
2021-05-18 10:56:55 +02:00
JeffProd 22bbfead6f
Update README limiter 2020-12-26 14:22:17 +01:00
hi019 494474aebd
Merge branch 'master' into master 2020-12-13 22:08:51 -05:00
Joey 2e30da966a
Merge pull request #1025 from Fenny/master
📦 Update utils and middleware configs
2020-11-24 07:24:04 +01:00
Fenny a468af7762 🩹 fix mutex lock 2020-11-23 07:44:06 +01:00
Fenny 323d9d89cc 🩹 fix manager logic 2020-11-23 07:38:42 +01:00
hi019 bc7b240158 improve mw 2020-11-21 12:36:16 -05:00
Fenny 8fe458011d 📦 add mapstore 2020-11-20 11:43:07 +01:00
hi019 e828c17554 Standardize MW docs 2020-11-17 12:12:49 -05:00
Fenny bb3a7fe5da 🩹 fix cache
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-11-17 08:33:07 +01:00
João Vitor 3df5ebbed6
changes request 2020-11-16 21:01:20 -03:00
João Vitor 7600e28cb9
update readme 2020-11-16 15:53:53 -03:00
Fenny 558d802cdd 🩹 Fix expiration check 2020-11-13 18:34:01 +01:00
Fenny 70a3a4dc21 🩹 fix limiter 2020-11-11 18:28:27 +01:00
Fenny 66ee4de7d8 🕊 rename token to key 2020-11-11 18:19:53 +01:00
Fenny 8bd50de610 🧹 housekeeping 2020-11-11 13:54:27 +01:00
Fenny 0d3d6d9fe8 📦 update fasthttp and storage interface 2020-11-06 01:52:05 +01:00
Fenny 7892ab62bf 📦 update Storage behaviour 2020-10-31 07:51:44 +01:00
Fenny a90ebb7098 ✏ add msgp tags
Co-Authored-By: Tom <tom@tdpain.net>
2020-10-28 02:35:49 +01:00
Fenny c863519f54 ✏ refactor unit test
Co-Authored-By: Tom <tom@tdpain.net>
2020-10-28 02:31:30 +01:00
Fenny ecdda95e15 💼 implement Storage 2020-10-28 02:29:47 +01:00
Fenny 32fdbf0ddf ✏ rename variable 2020-10-27 10:58:51 +01:00
Fenny 8334eb1f9e 🏬 clean storage in limiter 2020-10-27 08:12:53 +01:00
Tom c4dfe9a500
📦 Remove unused imports 2020-10-26 21:28:51 +00:00
Tom 847a7b5518
Merge remote-tracking branch 'origin/limiter-custom-store' into limiter-custom-store 2020-10-26 21:26:33 +00:00
Tom 66d2e7deda
📦 Switch to fiber.Storage and msgp 2020-10-26 21:25:30 +00:00
Tom 43e100f36c
📦 Make expiry of set keys cfg.Duration 2020-10-26 11:11:55 +00:00
Tom 3308a32a3a
📦 Change default configuration and add test for custom store 2020-10-26 11:11:55 +00:00