pub struct RefreshScope { /* private fields */ }Expand description
RefreshScope — marks beans that should be refreshed when config changes. RefreshScope — 标记在配置更改时应刷新的 bean。
Equivalent to Spring Cloud’s @RefreshScope.
等价于 Spring Cloud 的 @RefreshScope。
Manages refreshable values and fires events when configuration changes. 管理可刷新值,并在配置更改时触发事件。
Implementations§
Source§impl RefreshScope
impl RefreshScope
Sourcepub fn register(&self, key: impl Into<String>, initial_value: impl Into<String>)
pub fn register(&self, key: impl Into<String>, initial_value: impl Into<String>)
Register a refreshable value / 注册可刷新值
Sourcepub fn get(&self, key: &str) -> Option<String>
pub fn get(&self, key: &str) -> Option<String>
Get the current value of a refreshable / 获取可刷新值的当前值
Sourcepub fn add_listener(
&self,
listener: impl Fn(&ConfigChangeEvent) + Send + Sync + 'static,
)
pub fn add_listener( &self, listener: impl Fn(&ConfigChangeEvent) + Send + Sync + 'static, )
Add a change listener / 添加变更监听器
Sourcepub fn fire_event(&self, event: &ConfigChangeEvent)
pub fn fire_event(&self, event: &ConfigChangeEvent)
Fire a config change event and update the registered refreshables. 触发配置变更事件并更新已注册的可刷新值。
This method updates the refreshable value if registered, and notifies all registered listeners. 此方法更新已注册的可刷新值,并通知所有已注册的监听器。
Trait Implementations§
Source§impl Debug for RefreshScope
impl Debug for RefreshScope
Auto Trait Implementations§
impl Freeze for RefreshScope
impl RefUnwindSafe for RefreshScope
impl Send for RefreshScope
impl Sync for RefreshScope
impl Unpin for RefreshScope
impl UnsafeUnpin for RefreshScope
impl UnwindSafe for RefreshScope
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