pub struct RunnerSettings {
pub allow_network: bool,
pub max_concurrent: u32,
pub max_cpu_cores: f64,
pub max_memory_mb: u32,
pub max_timeout_secs: u32,
pub max_output_bytes: u64,
pub max_source_bytes: u64,
pub queue_timeout_secs: u32,
pub task_ttl_secs: u32,
pub languages: Option<String>,
}Expand description
代码运行器配置(资源限制与并发)。
需重启生效层:值在进程启动时烘焙进 LazyLock,改 DB 值后需重启才生效。
Fields§
§allow_network: bool是否允许容器联网。
max_concurrent: u32最大并发任务数。
max_cpu_cores: f64每任务最大 CPU 核数。
max_memory_mb: u32每任务最大内存(MB)。
max_timeout_secs: u32每任务最大执行超时(秒)。
max_output_bytes: u64每任务最大输出字节数。
max_source_bytes: u64每任务最大源码字节数。
queue_timeout_secs: u32排队等待超时(秒)。
task_ttl_secs: u32历史 task 保留时长(秒)。
languages: Option<String>语言白名单(逗号分隔,如 “python,node,rust”);None 表示不限制(全开)。
Implementations§
Source§impl RunnerSettings
impl RunnerSettings
Sourcepub fn clamp_max_concurrent(n: u32) -> u32
pub fn clamp_max_concurrent(n: u32) -> u32
将最大并发钳制到合法范围 [1, 64]。
Sourcepub fn clamp_max_cpu_cores(n: f64) -> f64
pub fn clamp_max_cpu_cores(n: f64) -> f64
将 CPU 核数钳制到合法范围 [0.1, 64.0];NaN 回退默认值。
Sourcepub fn clamp_max_memory_mb(n: u32) -> u32
pub fn clamp_max_memory_mb(n: u32) -> u32
将内存钳制到合法范围 [16, 65536]。
Sourcepub fn clamp_max_timeout_secs(n: u32) -> u32
pub fn clamp_max_timeout_secs(n: u32) -> u32
将超时钳制到合法范围 [1, ∞)。
Sourcepub fn clamp_max_output_bytes(n: u64) -> u64
pub fn clamp_max_output_bytes(n: u64) -> u64
将输出上限钳制到合法范围 [1, ∞)。
Sourcepub fn clamp_max_source_bytes(n: u64) -> u64
pub fn clamp_max_source_bytes(n: u64) -> u64
将源码上限钳制到合法范围 [1, ∞)。
Sourcepub fn clamp_queue_timeout_secs(n: u32) -> u32
pub fn clamp_queue_timeout_secs(n: u32) -> u32
将排队超时钳制到合法范围 [1, ∞)。
Sourcepub fn clamp_task_ttl_secs(n: u32) -> u32
pub fn clamp_task_ttl_secs(n: u32) -> u32
将 task 保留时长钳制到合法范围 [1, ∞)。
Sourcepub fn normalize_languages(s: &str) -> Option<String>
pub fn normalize_languages(s: &str) -> Option<String>
规范化语言白名单字符串:拆分、trim、转小写、去空;结果为空则返回 None。
Trait Implementations§
Source§impl Clone for RunnerSettings
impl Clone for RunnerSettings
Source§fn clone(&self) -> RunnerSettings
fn clone(&self) -> RunnerSettings
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RunnerSettings
impl Debug for RunnerSettings
Source§impl Default for RunnerSettings
impl Default for RunnerSettings
Source§impl<'de> Deserialize<'de> for RunnerSettings
impl<'de> Deserialize<'de> for RunnerSettings
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for RunnerSettings
impl PartialEq for RunnerSettings
Source§impl Serialize for RunnerSettings
impl Serialize for RunnerSettings
impl StructuralPartialEq for RunnerSettings
Auto Trait Implementations§
impl Freeze for RunnerSettings
impl RefUnwindSafe for RunnerSettings
impl Send for RunnerSettings
impl Sync for RunnerSettings
impl Unpin for RunnerSettings
impl UnsafeUnpin for RunnerSettings
impl UnwindSafe for RunnerSettings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.
§impl<T> Transportable for Twhere
T: Serialize + DeserializeOwned + 'static,
impl<T> Transportable for Twhere
T: Serialize + DeserializeOwned + 'static,
§fn transport_to_bytes(&self) -> Vec<u8> ⓘ
fn transport_to_bytes(&self) -> Vec<u8> ⓘ
Serialize the type to a byte vector for transport
§fn transport_from_bytes(bytes: &[u8]) -> Result<T, Error<Error>>
fn transport_from_bytes(bytes: &[u8]) -> Result<T, Error<Error>>
Deserialize the type from a byte slice