JMAP Registry API implementation - part 10
This commit is contained in:
@@ -92,7 +92,7 @@ impl BroadcastBatch<Vec<BroadcastEvent>> {
|
||||
let _ = serialized.write_leb128(object.to_id());
|
||||
}
|
||||
},
|
||||
BroadcastEvent::CacheInvalidation(items) => {
|
||||
BroadcastEvent::CacheInvalidate(items) => {
|
||||
serialized.push(7u8);
|
||||
let _ = serialized.write_leb128(items.len());
|
||||
for item in items {
|
||||
@@ -113,6 +113,16 @@ impl BroadcastBatch<Vec<BroadcastEvent>> {
|
||||
let _ = serialized.write_leb128(id);
|
||||
}
|
||||
}
|
||||
BroadcastEvent::CacheInvalidateAll => {
|
||||
serialized.push(8u8);
|
||||
}
|
||||
BroadcastEvent::MtaQueueStatus { is_running } => {
|
||||
if *is_running {
|
||||
serialized.push(9u8);
|
||||
} else {
|
||||
serialized.push(10u8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serialized
|
||||
@@ -223,9 +233,11 @@ where
|
||||
_ => return Err(()),
|
||||
});
|
||||
}
|
||||
Ok(Some(BroadcastEvent::CacheInvalidation(items)))
|
||||
Ok(Some(BroadcastEvent::CacheInvalidate(items)))
|
||||
}
|
||||
|
||||
8 => Ok(Some(BroadcastEvent::CacheInvalidateAll)),
|
||||
9 => Ok(Some(BroadcastEvent::MtaQueueStatus { is_running: true })),
|
||||
10 => Ok(Some(BroadcastEvent::MtaQueueStatus { is_running: false })),
|
||||
_ => Err(()),
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
use crate::broadcast::{BROADCAST_TOPIC, BroadcastBatch};
|
||||
use common::{
|
||||
BuildServer, Inner,
|
||||
ipc::{BroadcastEvent, PushEvent, PushNotification, RegistryChange},
|
||||
ipc::{BroadcastEvent, PushEvent, PushNotification, QueueEvent, RegistryChange},
|
||||
};
|
||||
use registry::types::EnumImpl;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
@@ -136,17 +136,24 @@ pub fn spawn_broadcast_subscriber(inner: Arc<Inner>, mut shutdown_rx: watch::Rec
|
||||
);
|
||||
}
|
||||
}
|
||||
BroadcastEvent::CacheInvalidation(changes) => {
|
||||
BroadcastEvent::CacheInvalidate(changes) => {
|
||||
inner.build_server().invalidate_local_caches(&changes).await;
|
||||
|
||||
}
|
||||
BroadcastEvent::CacheInvalidateAll => {
|
||||
inner.build_server().invalidate_all_local_caches();
|
||||
}
|
||||
BroadcastEvent::MtaQueueStatus { is_running } => {
|
||||
let _ = inner
|
||||
.ipc
|
||||
.queue_tx
|
||||
.send(QueueEvent::Paused(!is_running))
|
||||
.await;
|
||||
}
|
||||
BroadcastEvent::RegistryChange(change) => {
|
||||
match inner.build_server().reload_registry(change).await {
|
||||
match Box::pin(inner.build_server().reload_registry(change)).await {
|
||||
Ok(result) => {
|
||||
if let Some(new_core) = result.new_core {
|
||||
// Update core
|
||||
inner.shared_core.store(new_core.into());
|
||||
}
|
||||
result.log();
|
||||
}
|
||||
Err(err) => {
|
||||
trc::error!(
|
||||
@@ -228,7 +235,7 @@ fn log_event(event: &BroadcastEvent) -> trc::Value {
|
||||
trc::Value::Array(vec!["RegistryReload".into(), object.as_str().into()])
|
||||
}
|
||||
},
|
||||
BroadcastEvent::CacheInvalidation(items) => {
|
||||
BroadcastEvent::CacheInvalidate(items) => {
|
||||
let mut array = Vec::with_capacity(items.len() + 1);
|
||||
array.push("CacheInvalidation".into());
|
||||
for item in items {
|
||||
@@ -236,5 +243,13 @@ fn log_event(event: &BroadcastEvent) -> trc::Value {
|
||||
}
|
||||
trc::Value::Array(array)
|
||||
}
|
||||
BroadcastEvent::CacheInvalidateAll => "CacheInvalidateAll".into(),
|
||||
BroadcastEvent::MtaQueueStatus { is_running } => {
|
||||
if *is_running {
|
||||
"MtaQueueRunning".into()
|
||||
} else {
|
||||
"MtaQueuePaused".into()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,8 +445,10 @@ pub fn spawn_task_scheduler(inner: Arc<Inner>) {
|
||||
.await
|
||||
{
|
||||
Ok(result) => {
|
||||
if let Some(new_core) = result.new_core {
|
||||
if let Some(enterprise) = &new_core.enterprise {
|
||||
if !result.has_errors() {
|
||||
if let Some(enterprise) =
|
||||
server.inner.build_server().core.enterprise.as_ref()
|
||||
{
|
||||
let renew_in = if enterprise.license.is_near_expiration() {
|
||||
// Something went wrong during renewal, try again in 1 day or 1 hour,
|
||||
// depending on the time left on the license
|
||||
@@ -467,14 +469,13 @@ pub fn spawn_task_scheduler(inner: Arc<Inner>) {
|
||||
);
|
||||
}
|
||||
|
||||
// Update core
|
||||
server.inner.shared_core.store(new_core.into());
|
||||
|
||||
server
|
||||
.cluster_broadcast(common::ipc::BroadcastEvent::reload(
|
||||
ObjectType::Enterprise,
|
||||
))
|
||||
.await;
|
||||
} else {
|
||||
result.log();
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
||||
Reference in New Issue
Block a user