Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/RateLimiter.swift → Sources/Gatekeeper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct Rate {
}
}

public struct RateLimiter: Middleware {
public struct Gatekeeper: Middleware {
internal var cache: CacheProtocol

internal let limit: Int
Expand Down
18 changes: 9 additions & 9 deletions Tests/GatekeeperTests/GatekeeperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import Foundation

class GatekeeperTests: XCTestCase {
static var allTests = [
("testRateLimiter", testRateLimiter),
("testRateLimiterNoPeer", testRateLimiterNoPeer),
("testRateLimiterCountRefresh", testRateLimiterCountRefresh),
("testGateKeeper", testGateKeeper),
("testGateKeeperNoPeer", testGateKeeperNoPeer),
("testGateKeeperCountRefresh", testGateKeeperCountRefresh),
("testRefreshIntervalValues", testRefreshIntervalValues),
]

func testRateLimiter() {
let middleware = RateLimiter(rate: Rate(10, per: .second))
func testGateKeeper() {
let middleware = Gatekeeper(rate: Rate(10, per: .second))
let request = getHTTPSRequest()

for i in 1...11 {
Expand All @@ -38,8 +38,8 @@ class GatekeeperTests: XCTestCase {
}
}

func testRateLimiterNoPeer() {
let middleware = RateLimiter(rate: Rate(100, per: .second))
func testGateKeeperNoPeer() {
let middleware = Gatekeeper(rate: Rate(100, per: .second))
let request = getHTTPRequest()

do {
Expand All @@ -57,8 +57,8 @@ class GatekeeperTests: XCTestCase {
}
}

func testRateLimiterCountRefresh() {
let middleware = RateLimiter(rate: Rate(100, per: .second))
func testGateKeeperCountRefresh() {
let middleware = Gatekeeper(rate: Rate(100, per: .second))
let request = getHTTPSRequest()

for _ in 0..<50 {
Expand Down