Skip to main content

ServerConfig

Struct ServerConfig 

Source
pub struct ServerConfig {
Show 17 fields pub concurrency: usize, pub queues: HashMap<String, i32>, pub strict_priority: bool, pub task_check_interval: Duration, pub delayed_task_check_interval: Duration, pub shutdown_timeout: Duration, pub health_check_interval: Duration, pub group_grace_period: Duration, pub group_max_delay: Option<Duration>, pub group_max_size: Option<usize>, pub janitor_interval: Duration, pub janitor_batch_size: usize, pub heartbeat_interval: Duration, pub group_aggregator_enabled: bool, pub periodic_task_manager_enabled: bool, pub periodic_task_manager_check_interval: Duration, pub acl_tenant: Option<String>,
}
Expand description

服务器配置 Server configuration

Fields§

§concurrency: usize

并发工作者数量 Number of concurrent workers

§queues: HashMap<String, i32>

队列配置,键为队列名称,值为优先级 Queue configuration, key is queue name, value is priority

§strict_priority: bool

是否使用严格优先级 Whether to use strict priority

§task_check_interval: Duration

任务检查间隔 Task check interval

§delayed_task_check_interval: Duration

延迟任务检查间隔 Delayed task check interval

§shutdown_timeout: Duration

关闭超时时间 Shutdown timeout

§health_check_interval: Duration

健康检查间隔 Health check interval

§group_grace_period: Duration

组宽限期 Group grace period

§group_max_delay: Option<Duration>

组最大延迟 Maximum group delay

§group_max_size: Option<usize>

组最大大小 Maximum group size

§janitor_interval: Duration

清理任务间隔 Janitor interval

§janitor_batch_size: usize

清理任务批量大小 Janitor batch size

§heartbeat_interval: Duration

心跳间隔 Heartbeat interval

§group_aggregator_enabled: bool

是否启用组聚合器 Whether to enable group aggregator

§periodic_task_manager_enabled: bool

是否启用周期性任务管理器 Whether to enable periodic task manager

§periodic_task_manager_check_interval: Duration

周期性任务管理器检查间隔 Periodic task manager check interval

§acl_tenant: Option<String>

ACL 租户名称(用户名),用作 ACL 前缀 ACL tenant name (username), used as ACL prefix When set, ACL feature is automatically enabled

Implementations§

Source§

impl ServerConfig

Source

pub fn new() -> Self

创建新的服务器配置 Create a new server configuration

Source

pub fn concurrency(self, concurrency: usize) -> Self

设置并发数 Set the number of concurrent workers

Source

pub fn queues(self, queues: HashMap<String, i32>) -> Self

设置队列配置 Set the queue configuration

Source

pub fn add_queue<S: AsRef<str>>(self, name: S, priority: i32) -> Result<Self>

添加队列 Add a queue

Source

pub fn strict_priority(self, strict: bool) -> Self

设置严格优先级 Set strict priority

Source

pub fn task_check_interval(self, interval: Duration) -> Self

设置任务检查间隔 Set the task check interval

Source

pub fn delayed_task_check_interval(self, interval: Duration) -> Self

设置延迟任务检查间隔 Set the delayed task check interval

Source

pub fn shutdown_timeout(self, timeout: Duration) -> Self

设置关闭超时时间 Set the shutdown timeout

Source

pub fn health_check_interval(self, interval: Duration) -> Self

设置健康检查间隔 Set the health check interval

Source

pub fn group_grace_period(self, grace_period: Duration) -> Result<Self>

设置组宽限期 Set the group grace period

Source

pub fn group_max_delay(self, max_delay: Duration) -> Self

设置组最大延迟 Set the maximum group delay

Source

pub fn group_max_size(self, max_size: usize) -> Self

设置组最大大小 Set the maximum group size

Source

pub fn janitor_interval(self, interval: Duration) -> Self

设置清理任务间隔 Set the janitor interval

Source

pub fn janitor_batch_size(self, batch_size: usize) -> Self

设置清理任务批量大小 Set the janitor batch size

Source

pub fn enable_group_aggregator(self, enabled: bool) -> Self

启用组聚合器 Enable group aggregator

Source

pub fn enable_periodic_task_manager(self, enabled: bool) -> Self

启用周期性任务管理器 Enable periodic task manager

Source

pub fn periodic_task_manager_check_interval(self, interval: Duration) -> Self

设置周期性任务管理器检查间隔 Set periodic task manager check interval

Source

pub fn acl_tenant<S: Into<String>>(self, tenant: S) -> Self

设置 ACL 租户名称 Set ACL tenant name

当设置租户名称时,ACL 特性会自动启用,队列名称将自动添加租户前缀 When tenant name is set, ACL feature is automatically enabled and queue names will have the tenant prefix added

Source

pub fn get_queue_name_with_prefix(&self, queue: &str) -> String

获取带 ACL 前缀的队列名称 Get queue name with ACL prefix

如果配置了租户,返回 {tenant:queue},否则返回原始队列名 If tenant is configured, returns {tenant:queue}, otherwise returns original queue name 注意:默认队列(DEFAULT_QUEUE_NAME)不添加前缀,这是所有租户共享的公共队列 Note: Default queue (DEFAULT_QUEUE_NAME) is not prefixed, it’s a shared public queue for all tenants

Source

pub fn get_queues_with_prefix(&self) -> HashMap<String, i32>

获取所有带 ACL 前缀的队列 Get all queues with ACL prefix

返回一个新的 HashMap,其中所有队列名称都添加了 ACL 前缀(如果配置了租户) Returns a new HashMap where all queue names have the ACL prefix added (if tenant is configured)

Source

pub fn validate(&self) -> Result<()>

验证配置 Validate the configuration

Trait Implementations§

Source§

impl Clone for ServerConfig

Source§

fn clone(&self) -> ServerConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ServerConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more