|
|
|
|
@ -4,9 +4,16 @@ use std::{
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
use conduit_config::rate_limiting::{ |
|
|
|
|
ClientRestriction, DocumentRestrictions, FederationRestriction, |
|
|
|
|
ClientRestriction, Config, ConfigPreset, DocumentRestrictions, FederationRestriction, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const PRESETS: [ConfigPreset; 4] = [ |
|
|
|
|
ConfigPreset::PrivateSmall, |
|
|
|
|
ConfigPreset::PrivateMedium, |
|
|
|
|
ConfigPreset::PublicMedium, |
|
|
|
|
ConfigPreset::PublicLarge, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
pub fn run() { |
|
|
|
|
let mut markdown_text = String::new(); |
|
|
|
|
|
|
|
|
|
@ -15,10 +22,24 @@ pub fn run() {
|
|
|
|
|
markdown_text.push_str(&format!("{}\n", $restriction_kind::container_doc_comment())); |
|
|
|
|
for (restriction, comment) in $restriction_kind::variant_doc_comments() { |
|
|
|
|
markdown_text.push_str(&format!( |
|
|
|
|
"##### `{}`\n{}\n", |
|
|
|
|
restriction_to_string(&restriction), |
|
|
|
|
"##### `{}`\n{}\n###### Defaults:\n| Preset | Global Timeframe | Global Burst Capacity | Target Timeframe | Target Burst Capacity |\n| --- | --- | --- | --- | --- |\n", |
|
|
|
|
variant_to_string(&restriction), |
|
|
|
|
comment |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
for preset in PRESETS { |
|
|
|
|
let preset_config = Config::get_preset(preset); |
|
|
|
|
let global = preset_config.global.get(&restriction.into()); |
|
|
|
|
let target = preset_config.target.get(&restriction.into()); |
|
|
|
|
markdown_text.push_str(&format!( |
|
|
|
|
"| {} | {} | {} | {} | {} |\n", |
|
|
|
|
variant_to_string(&preset), |
|
|
|
|
global.timeframe, |
|
|
|
|
global.burst_capacity, |
|
|
|
|
target.timeframe, |
|
|
|
|
target.burst_capacity, |
|
|
|
|
)) |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
@ -37,7 +58,7 @@ pub fn run() {
|
|
|
|
|
file.write_all(markdown_text.as_bytes()).unwrap(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn restriction_to_string<T: serde::Serialize>(restriction: &T) -> String { |
|
|
|
|
fn variant_to_string<T: serde::Serialize>(restriction: &T) -> String { |
|
|
|
|
// Maybe there is a better way to convert it to snake_case without extra dependencies added
|
|
|
|
|
// to Cargo.lock
|
|
|
|
|
serde_json::to_string(restriction) |
|
|
|
|
|