tiny update
This commit is contained in:
+15
-15
@@ -1,13 +1,5 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
const DEFAULT_MAX_CONCURRENT_EXECUTIONS: usize = 16;
|
|
||||||
const DEFAULT_MAX_CONNECTED_DEVICES: usize = 10;
|
|
||||||
const DEFAULT_MAX_EXECUTION_SECS: u64 = 3600;
|
|
||||||
const DEFAULT_MAX_COMMAND_LENGTH: usize = 65_536;
|
|
||||||
const DEFAULT_MAX_RESULT_BYTES: usize = 10 * 1024 * 1024;
|
|
||||||
const DEFAULT_PING_INTERVAL_SECS: u64 = 30;
|
|
||||||
const DEFAULT_PING_TIMEOUT_SECS: u64 = 10;
|
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub max_concurrent_executions: usize,
|
pub max_concurrent_executions: usize,
|
||||||
pub max_connected_devices: usize,
|
pub max_connected_devices: usize,
|
||||||
@@ -19,29 +11,37 @@ pub struct Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
const DEFAULT_MAX_CONCURRENT_EXECUTIONS: usize = 16;
|
||||||
|
const DEFAULT_MAX_CONNECTED_DEVICES: usize = 10;
|
||||||
|
const DEFAULT_MAX_EXECUTION_SECS: u64 = 3600;
|
||||||
|
const DEFAULT_MAX_COMMAND_LENGTH: usize = 65_536;
|
||||||
|
const DEFAULT_MAX_RESULT_BYTES: usize = 10 * 1024 * 1024;
|
||||||
|
const DEFAULT_PING_INTERVAL_SECS: u64 = 30;
|
||||||
|
const DEFAULT_PING_TIMEOUT_SECS: u64 = 10;
|
||||||
|
|
||||||
pub fn from_env() -> Self {
|
pub fn from_env() -> Self {
|
||||||
Self {
|
Self {
|
||||||
max_concurrent_executions: parse_env(
|
max_concurrent_executions: parse_env(
|
||||||
"MAX_CONCURRENT_EXECUTIONS",
|
"MAX_CONCURRENT_EXECUTIONS",
|
||||||
DEFAULT_MAX_CONCURRENT_EXECUTIONS,
|
Self::DEFAULT_MAX_CONCURRENT_EXECUTIONS,
|
||||||
),
|
),
|
||||||
max_connected_devices: parse_env(
|
max_connected_devices: parse_env(
|
||||||
"MAX_CONNECTED_DEVICES",
|
"MAX_CONNECTED_DEVICES",
|
||||||
DEFAULT_MAX_CONNECTED_DEVICES,
|
Self::DEFAULT_MAX_CONNECTED_DEVICES,
|
||||||
),
|
),
|
||||||
max_execution_time: Duration::from_secs(parse_env(
|
max_execution_time: Duration::from_secs(parse_env(
|
||||||
"MAX_EXECUTION_SECS",
|
"MAX_EXECUTION_SECS",
|
||||||
DEFAULT_MAX_EXECUTION_SECS,
|
Self::DEFAULT_MAX_EXECUTION_SECS,
|
||||||
)),
|
)),
|
||||||
max_command_length: parse_env("MAX_COMMAND_LENGTH", DEFAULT_MAX_COMMAND_LENGTH),
|
max_command_length: parse_env("MAX_COMMAND_LENGTH", Self::DEFAULT_MAX_COMMAND_LENGTH),
|
||||||
max_result_bytes: parse_env("MAX_RESULT_BYTES", DEFAULT_MAX_RESULT_BYTES),
|
max_result_bytes: parse_env("MAX_RESULT_BYTES", Self::DEFAULT_MAX_RESULT_BYTES),
|
||||||
ping_interval: Duration::from_secs(parse_env(
|
ping_interval: Duration::from_secs(parse_env(
|
||||||
"PING_INTERVAL_SECS",
|
"PING_INTERVAL_SECS",
|
||||||
DEFAULT_PING_INTERVAL_SECS,
|
Self::DEFAULT_PING_INTERVAL_SECS,
|
||||||
)),
|
)),
|
||||||
ping_timeout: Duration::from_secs(parse_env(
|
ping_timeout: Duration::from_secs(parse_env(
|
||||||
"PING_TIMEOUT_SECS",
|
"PING_TIMEOUT_SECS",
|
||||||
DEFAULT_PING_TIMEOUT_SECS,
|
Self::DEFAULT_PING_TIMEOUT_SECS,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user