mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
make reload_handles optional for creating Services
This will be useful for instantiating services in CLI subcommands, which have different requirements around observeability.
This commit is contained in:
parent
b03c2a15b3
commit
86481fd651
4 changed files with 9 additions and 5 deletions
|
|
@ -80,7 +80,7 @@ pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
|
||||||
.map_err(Error::DatabaseError)?,
|
.map_err(Error::DatabaseError)?,
|
||||||
));
|
));
|
||||||
|
|
||||||
Services::build(db, config, reload_handles)
|
Services::build(db, config, Some(reload_handles))
|
||||||
.map_err(Error::InitializeServices)?
|
.map_err(Error::InitializeServices)?
|
||||||
.install();
|
.install();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ impl Services {
|
||||||
>(
|
>(
|
||||||
db: &'static D,
|
db: &'static D,
|
||||||
config: Config,
|
config: Config,
|
||||||
reload_handles: FilterReloadHandles,
|
reload_handles: Option<FilterReloadHandles>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
appservice: appservice::Service::build(db)?,
|
appservice: appservice::Service::build(db)?,
|
||||||
|
|
|
||||||
|
|
@ -1134,7 +1134,11 @@ impl Service {
|
||||||
backend,
|
backend,
|
||||||
filter,
|
filter,
|
||||||
} => {
|
} => {
|
||||||
let handles = &services().globals.reload_handles;
|
let Some(handles) = &services().globals.reload_handles else {
|
||||||
|
return Ok(RoomMessageEventContent::text_plain(
|
||||||
|
"Reloading filters is disabled",
|
||||||
|
));
|
||||||
|
};
|
||||||
let handle = match backend {
|
let handle = match backend {
|
||||||
TracingBackend::Log => &handles.log,
|
TracingBackend::Log => &handles.log,
|
||||||
TracingBackend::Flame => &handles.flame,
|
TracingBackend::Flame => &handles.flame,
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ pub(crate) mod marker {
|
||||||
|
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
pub(crate) db: &'static dyn Data,
|
||||||
pub(crate) reload_handles: FilterReloadHandles,
|
pub(crate) reload_handles: Option<FilterReloadHandles>,
|
||||||
|
|
||||||
// actual_destination, host
|
// actual_destination, host
|
||||||
pub(crate) actual_destination_cache: Arc<RwLock<WellKnownMap>>,
|
pub(crate) actual_destination_cache: Arc<RwLock<WellKnownMap>>,
|
||||||
|
|
@ -200,7 +200,7 @@ impl Service {
|
||||||
pub(crate) fn load(
|
pub(crate) fn load(
|
||||||
db: &'static dyn Data,
|
db: &'static dyn Data,
|
||||||
config: Config,
|
config: Config,
|
||||||
reload_handles: FilterReloadHandles,
|
reload_handles: Option<FilterReloadHandles>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let keypair = db.load_keypair();
|
let keypair = db.load_keypair();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue