Skip to content

Commit 0703830

Browse files
committed
added documentation for GET /cfg
1 parent a7db507 commit 0703830

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

primitives/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ name = "validator_messages_list_query"
7272
[[example]]
7373
name = "validator_messages_list_response"
7474

75+
[[example]]
76+
name = "get_cfg_response"
77+
7578
[dependencies]
7679
# (De)Serialization
7780
serde = { version = "1.0", features = ["derive"] }
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
use primitives::Config;
2+
use serde_json::{from_value, json};
3+
4+
fn main() {
5+
let json = json!({
6+
"max_channels":512,
7+
"channels_find_limit":200,
8+
"campaigns_find_limit":200,
9+
"spendable_find_limit":200,
10+
"wait_time":{"secs":0,"nanos":500000000},
11+
"msgs_find_limit":10,
12+
"analytics_find_limit":5000,
13+
"analytics_maxtime":{"secs":20,"nanos":0},
14+
"heartbeat_time":{"secs":30,"nanos":0},
15+
"health_threshold_promilles":950,
16+
"health_unsignable_promilles":750,
17+
"propagation_timeout":{"secs":2,"nanos":0},
18+
"fetch_timeout":{"secs":5,"nanos":0},
19+
"all_campaigns_timeout":{"secs":5,"nanos":0},
20+
"channel_tick_timeout":{"secs":8,"nanos":0},
21+
"ip_rate_limit":{"type":"ip","timeframe":1200000},
22+
"creators_whitelist":[],
23+
"validators_whitelist":[],
24+
"admins":["0x80690751969B234697e9059e04ed72195c3507fa"],
25+
"chain":{
26+
"Ganache #1337": {
27+
"chain_id":1337,
28+
"rpc":"http://localhost:1337/",
29+
"outpace":"0xAbc27d46a458E2e49DaBfEf45ca74dEDBAc3DD06",
30+
"token":{
31+
"Mocked TOKEN 1337":{
32+
"min_campaign_budget":"1000000000000000000",
33+
"min_validator_fee":"1000000000000",
34+
"precision":18,
35+
"address":"0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E"
36+
}
37+
}
38+
},
39+
"Ganache #1":{
40+
"chain_id":1,
41+
"rpc":"http://localhost:8545/",
42+
"outpace":"0x26CBc2eAAe377f6Ac4b73a982CD1125eF4CEC96f",
43+
"token":{
44+
"Mocked TOKEN 1":{
45+
"min_campaign_budget":"1000000000000000000",
46+
"min_validator_fee":"1000000000000",
47+
"precision":18,
48+
"address":"0x12a28f2bfBFfDf5842657235cC058242f40fDEa6"
49+
}
50+
}
51+
}
52+
},
53+
"platform":{
54+
"url":"https://platform.adex.network/",
55+
"keep_alive_interval":{"secs":1200,"nanos":0}
56+
},
57+
"limits":{
58+
"units_for_slot":{
59+
"max_campaigns_earning_from":25,
60+
"global_min_impression_price":"1000000"
61+
}
62+
}
63+
});
64+
let val = from_value::<Config>(json).expect("should convert");
65+
// assert!(from_value::<Config>(json).is_ok());
66+
}

primitives/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ impl Default for Environment {
4747
}
4848
}
4949

50+
/// Examples:
51+
/// ```
52+
#[doc = include_str!("../../primitives/examples/get_cfg_response.rs")]
53+
/// ```
5054
#[derive(Serialize, Deserialize, Debug, Clone)]
5155
pub struct Config {
5256
/// The maximum number of [`Channel`](crate::Channel)s that the worker

sentry/src/routes.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,22 @@
466466
//!
467467
//! See [GET `/v5/analytics`](#get-v5analytics)
468468
//!
469+
//! #### GET `/cfg`
470+
//!
471+
//! Gets the config that the validator is running on.
472+
//!
473+
//! The route is handled by [`sentry::routes::cfg::get_config()`]
474+
//!
475+
//! Response: [`Config`](primitives::Config)
476+
//!
477+
//! ##### Examples
478+
//!
479+
//! Response:
480+
//!
481+
//! ```
482+
#![doc = include_str!("../../primitives/examples/get_cfg_response.rs")]
483+
//! ```
484+
//!
469485
//! [`Adapter`]: adapter::Adapter
470486
//! [`Address`]: primitives::Address
471487
//! [`AllowedKey`]: primitives::analytics::query::AllowedKey

sentry/src/routes/cfg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use primitives::Config;
99

1010
use crate::Application;
1111

12-
/// `GET /cfg` request
12+
/// GET `/cfg` request
13+
///
14+
/// Response: [`Config`]
1315
pub async fn config<C: Locked + 'static>(
1416
Extension(app): Extension<Arc<Application<C>>>,
1517
) -> Json<Config> {

0 commit comments

Comments
 (0)