-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ratelimit): Return Duration from Ratelimit functions #6283
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ mod maps_integration; | |
use std::cmp::max; | ||
use std::collections::HashMap; | ||
use std::path::Path; | ||
use std::time::Duration; | ||
|
||
use anyhow::{anyhow, bail, ensure, format_err, Context as _, Result}; | ||
|
||
|
@@ -111,9 +112,9 @@ pub struct WebxdcInfo { | |
/// Address to be used for `window.webxdc.selfAddr` in JS land. | ||
pub self_addr: String, | ||
|
||
/// Milliseconds to wait before calling `sendUpdate()` again since the last call. | ||
/// Time to wait before calling `sendUpdate()` again since the last call. | ||
/// Should be exposed to `window.sendUpdateInterval` in JS land. | ||
pub send_update_interval: usize, | ||
pub send_update_interval: Duration, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope i don't break things here? This is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The best way to find out is adding a JSON-RPC test, I am also not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's already Still, this EDIT: Webxdc manifest files doesn't contain |
||
|
||
/// Maximum number of bytes accepted for a serialized update object. | ||
/// Should be exposed to `window.sendUpdateMaxSize` in JS land. | ||
|
@@ -961,7 +962,7 @@ impl Message { | |
request_integration, | ||
internet_access, | ||
self_addr, | ||
send_update_interval: context.ratelimit.read().await.update_interval(), | ||
send_update_interval: context.ratelimit.read().await.min_send_interval(), | ||
send_update_max_size: RECOMMENDED_FILE_SIZE as usize, | ||
}) | ||
} | ||
|
@@ -2262,7 +2263,7 @@ sth_for_the = "future""# | |
let info = instance.get_webxdc_info(&t).await?; | ||
assert_eq!(info.name, "minimal.xdc"); | ||
assert_eq!(info.icon, WEBXDC_DEFAULT_ICON.to_string()); | ||
assert_eq!(info.send_update_interval, 10000); | ||
assert_eq!(info.send_update_interval, Duration::new(10, 0)); | ||
assert_eq!(info.send_update_max_size, RECOMMENDED_FILE_SIZE as usize); | ||
|
||
let mut instance = create_webxdc_instance( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the future i suggest to add the
_ms
suffix, otherwise one can think it's in seconds. Moreover we have other intervals in API which are indeed in seconds