soph_redis/support/
instance.rsuse crate::{async_trait, config, error::Error, Redis};
use soph_config::support::config;
use soph_core::{
error::ContainerError,
support::{app, Container},
traits::{ErrorTrait, InstanceTrait},
Result,
};
#[async_trait]
impl InstanceTrait for Redis {
type Config = config::Redis;
async fn register(_: &Container) -> Result<Self, ContainerError>
where
Self: Sized,
{
let config = config().parse::<Self::Config>()?;
Ok(Self::try_from_config(config).await.map_err(Error::wrap)?)
}
async fn boot() -> Result<(), ContainerError>
where
Self: Sized,
{
let redis = app().resolve::<Self>()?;
redis.ping().await.map_err(Error::wrap)?;
Ok(())
}
}