pub struct Config<T>(/* private fields */);Expand description
A typed configuration handle declared as a module-level static:
static CHECKOUT: Config<Checkout> = Config::new("checkout");.
See the module documentation for schema rules, file layouts, and live
updates. By default Config::new declares a service-scoped config; call
shared or global for app-wide scope.
Implementations§
Source§impl<T: ConfigType> Config<T>
impl<T: ConfigType> Config<T>
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Declares a config with the given name.
This constructor is const so it can initialize a module-scope static,
and nothing is read until get is called. name must be a
string literal so Encore can parse it statically.
Declares the config with shared app-wide scope rather than service scope.
Any service may read a shared config, and each service that does is recorded as using it. See scope.
Sourcepub const fn global(self) -> Self
pub const fn global(self) -> Self
Declares the config with global app-wide scope, making it available to every service without tracking per-service usage. See scope.
Sourcepub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
pub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
Attaches a key/value tag to the config (for example, .tag("data", "pci"))
for policy and governance tooling.
Call once per tag with unique keys. Both key and value must be string
literals so Encore can parse them statically. Keys must start with a letter,
contain only lowercase letters, digits, _, and -, and must not start
with encore (reserved for Encore’s own tags). Values use the same
character set or may be empty. Each key and value is at most 63 characters,
and a config may have at most 32 tags.
static CHECKOUT: Config<Checkout> = Config::new("checkout").tag("team", "payments");Sourcepub fn on_change(&self, f: impl Fn(Value<T>) + Send + Sync + 'static)
pub fn on_change(&self, f: impl Fn(Value<T>) + Send + Sync + 'static)
Registers a callback f invoked whenever the config value changes while
the process is running.
Rapid consecutive updates are coalesced so f receives the latest value.
Callbacks run on the runtime’s threads, so keep f fast and spawn async
tasks for any blocking or I/O work.
Auto Trait Implementations§
impl<T> !Freeze for Config<T>
impl<T> !RefUnwindSafe for Config<T>
impl<T> !UnwindSafe for Config<T>
impl<T> Forget for Config<T>
impl<T> Move for Config<T>
impl<T> Send for Config<T>
impl<T> Sync for Config<T>
impl<T> Unpin for Config<T>
impl<T> UnsafeUnpin for Config<T>where
&'static str: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
*const ArcInner<Config> is !null: UnsafeUnpin,
PhantomData<ArcInner<Config>>: UnsafeUnpin,
PhantomData<Option<Arc<Config>>>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const ArcInner<Revision> is !null: UnsafeUnpin,
PhantomData<ArcInner<Revision>>: UnsafeUnpin,
*const ArcInner<T> is !null: UnsafeUnpin,
PhantomData<ArcInner<T>>: UnsafeUnpin,
PhantomData<Arc<T>>: UnsafeUnpin,
PhantomData<fn() -> T>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request