-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from fastly/jake/erl-test
⏫ Bump up the Fastly SDK to latest version and uncomment the test for the Edge Rate Limiting API
- Loading branch information
Showing
4 changed files
with
30 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
//! A guest program to test that edge-rate-limiting API is implemented. | ||
|
||
//use std::time::Duration; | ||
use std::time::Duration; | ||
|
||
//use fastly::erl::{CounterDuration, Penaltybox, RateCounter, RateWindow, ERL}; | ||
use fastly::erl::{CounterDuration, Penaltybox, RateCounter, RateWindow, ERL}; | ||
|
||
fn main() { | ||
// let entry = "entry"; | ||
let entry = "entry"; | ||
|
||
// let rc = RateCounter::open("rc"); | ||
// let pb = Penaltybox::open("pb"); | ||
// let erl = ERL::open(rc, pb); | ||
let rc = RateCounter::open("rc"); | ||
let pb = Penaltybox::open("pb"); | ||
let erl = ERL::open(rc, pb); | ||
|
||
// let not_blocked = erl | ||
// .check_rate(entry, 1, RateWindow::TenSecs, 100, Duration::from_secs(300)) | ||
// .unwrap(); | ||
// assert_eq!(not_blocked, false); | ||
let not_blocked = erl | ||
.check_rate(entry, 1, RateWindow::TenSecs, 100, Duration::from_secs(300)) | ||
.unwrap(); | ||
assert_eq!(not_blocked, false); | ||
|
||
// let rc2 = RateCounter::open("rc"); | ||
// let rate_1 = rc2.lookup_rate(entry, RateWindow::OneSec).unwrap(); | ||
// assert_eq!(rate_1, 0); | ||
let rc2 = RateCounter::open("rc"); | ||
let rate_1 = rc2.lookup_rate(entry, RateWindow::OneSec).unwrap(); | ||
assert_eq!(rate_1, 0); | ||
|
||
// let count10 = rc2.lookup_count(entry, CounterDuration::TenSec).unwrap(); | ||
// assert_eq!(count10, 0); | ||
let count10 = rc2.lookup_count(entry, CounterDuration::TenSec).unwrap(); | ||
assert_eq!(count10, 0); | ||
|
||
// assert!(rc2.increment(entry, 600).is_ok()); | ||
assert!(rc2.increment(entry, 600).is_ok()); | ||
|
||
// let pb2 = Penaltybox::open("pb"); | ||
// let not_in_pb = pb2.has(entry).unwrap(); | ||
// assert_eq!(not_in_pb, false); | ||
let pb2 = Penaltybox::open("pb"); | ||
let not_in_pb = pb2.has(entry).unwrap(); | ||
assert_eq!(not_in_pb, false); | ||
|
||
// assert!(pb2.add(entry, Duration::from_secs(300)).is_ok()); | ||
assert!(pb2.add(entry, Duration::from_secs(300)).is_ok()); | ||
} |