pub struct PostgresStateStoreConfig { /* private fields */ }Expand description
PostgreSQL StateStore configuration.
PostgreSQL StateStore support requires the postgres feature and is intended
for remote durable control-plane state. This always-available config stays
pure data until it is passed
to crate::state::config::StateStoreConfig::postgres and opened through
crate::StateStore::connect. Password bytes are only exposed at the
final authentication boundary inside the private PostgreSQL backend.
§Examples
let password = storage_kit::state::config::Password::from_string("state-store-secret")?;
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost(
"storage_kit_state",
"storage_kit",
)
.with_password(password)
.with_port(15432)
.with_operation_timeout(std::time::Duration::from_secs(2))?;
let state_config = storage_kit::state::config::StateStoreConfig::postgres(config.clone());
assert_eq!(config.host(), "127.0.0.1");
assert_eq!(config.port(), 15432);
assert_eq!(config.tls_mode(), storage_kit::state::config::PostgresStateStoreTlsMode::Disable);
assert!(!format!("{config:?}").contains("state-store-secret"));
assert_eq!(state_config.validate(), Ok(()));Implementations§
Source§impl PostgresStateStoreConfig
impl PostgresStateStoreConfig
Sourcepub fn new(
host: impl Into<String>,
database: impl Into<String>,
username: impl Into<String>,
) -> Self
pub fn new( host: impl Into<String>, database: impl Into<String>, username: impl Into<String>, ) -> Self
Builds a PostgreSQL StateStore config.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::new(
"127.0.0.1",
"storage_kit_state",
"storage_kit",
);
if config.host() != "127.0.0.1" {
return Err("unexpected host".into());
}Sourcepub fn localhost(
database: impl Into<String>,
username: impl Into<String>,
) -> Self
pub fn localhost( database: impl Into<String>, username: impl Into<String>, ) -> Self
Builds a PostgreSQL StateStore config for 127.0.0.1.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost(
"storage_kit_state",
"storage_kit",
);
if config.host() != "127.0.0.1" {
return Err("unexpected host".into());
}Sourcepub fn with_port(self, port: u16) -> Self
pub fn with_port(self, port: u16) -> Self
Replaces the PostgreSQL server port.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_port(15432);
if config.port() != 15432 {
return Err("unexpected port".into());
}Sourcepub fn with_password(self, password: Password) -> Self
pub fn with_password(self, password: Password) -> Self
Sets the password used by PostgreSQL authentication.
§Examples
let password = storage_kit::state::config::Password::from_string("secret")?;
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_password(password);
if config.password().is_none() {
return Err("expected password".into());
}Sourcepub fn without_password(self) -> Self
pub fn without_password(self) -> Self
Clears any configured password.
§Examples
let password = storage_kit::state::config::Password::from_string("secret")?;
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_password(password)
.without_password();
if config.password().is_some() {
return Err("unexpected password".into());
}Sourcepub fn with_operation_timeout(
self,
timeout: Duration,
) -> Result<Self, StateStoreError>
pub fn with_operation_timeout( self, timeout: Duration, ) -> Result<Self, StateStoreError>
Replaces the per-operation timeout.
§Errors
Returns an invalid-config error when the timeout cannot be represented as milliseconds.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_operation_timeout(std::time::Duration::from_millis(250))?;
if config.operation_timeout().as_millis() != 250 {
return Err("unexpected timeout".into());
}Sourcepub fn host(&self) -> &str
pub fn host(&self) -> &str
Returns the configured host.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::new(
"db.internal",
"storage_kit_state",
"storage_kit",
);
assert_eq!(config.host(), "db.internal");Sourcepub fn port(&self) -> u16
pub fn port(&self) -> u16
Returns the configured port.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_port(15432);
assert_eq!(config.port(), 15432);Sourcepub fn database(&self) -> &str
pub fn database(&self) -> &str
Returns the configured database name.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost(
"storage_kit_state",
"storage_kit",
);
assert_eq!(config.database(), "storage_kit_state");Sourcepub fn username(&self) -> &str
pub fn username(&self) -> &str
Returns the configured username.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost(
"storage_kit_state",
"storage_kit",
);
assert_eq!(config.username(), "storage_kit");Sourcepub fn password(&self) -> Option<&Password>
pub fn password(&self) -> Option<&Password>
Returns the configured password, if present.
§Examples
let password = storage_kit::state::config::Password::from_string("secret")?;
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_password(password);
assert!(config.password().is_some());Sourcepub fn tls_mode(&self) -> PostgresStateStoreTlsMode
pub fn tls_mode(&self) -> PostgresStateStoreTlsMode
Returns the configured TLS mode.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user");
assert_eq!(
config.tls_mode(),
storage_kit::state::config::PostgresStateStoreTlsMode::Disable
);Sourcepub fn operation_timeout(&self) -> Duration
pub fn operation_timeout(&self) -> Duration
Returns the configured operation timeout.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user")
.with_operation_timeout(std::time::Duration::from_millis(750))?;
assert_eq!(config.operation_timeout().as_millis(), 750);Sourcepub fn validate(&self) -> Result<(), StateStoreError>
pub fn validate(&self) -> Result<(), StateStoreError>
Validates PostgreSQL StateStore configuration.
§Errors
Returns an invalid-config error when text fields, port, or operation timeout are unusable.
§Examples
let config = storage_kit::state::config::PostgresStateStoreConfig::localhost("db", "user");
config.validate()?;
let invalid = storage_kit::state::config::PostgresStateStoreConfig::new("", "db", "user");
assert!(matches!(
invalid.validate(),
Err(storage_kit::StateStoreError::InvalidConfig(_))
));Trait Implementations§
Source§impl Clone for PostgresStateStoreConfig
impl Clone for PostgresStateStoreConfig
Source§impl Debug for PostgresStateStoreConfig
impl Debug for PostgresStateStoreConfig
Source§impl<'de> Deserialize<'de> for PostgresStateStoreConfig
impl<'de> Deserialize<'de> for PostgresStateStoreConfig
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>,
Source§impl From<PostgresStateStoreConfig> for StateStoreConfig
impl From<PostgresStateStoreConfig> for StateStoreConfig
Source§fn from(config: PostgresStateStoreConfig) -> Self
fn from(config: PostgresStateStoreConfig) -> Self
Auto Trait Implementations§
impl Freeze for PostgresStateStoreConfig
impl RefUnwindSafe for PostgresStateStoreConfig
impl Send for PostgresStateStoreConfig
impl Sync for PostgresStateStoreConfig
impl Unpin for PostgresStateStoreConfig
impl UnsafeUnpin for PostgresStateStoreConfig
impl UnwindSafe for PostgresStateStoreConfig
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.