Move debt reporter into syndicate-server
This commit is contained in:
parent
1e12d73c50
commit
87338ce47a
|
@ -32,7 +32,6 @@ fn says(who: AnyValue, what: AnyValue) -> AnyValue {
|
|||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
syndicate::convenient_logging()?;
|
||||
syndicate::actor::start_debt_reporter();
|
||||
Actor::new().boot(syndicate::name!("producer"), |t| {
|
||||
let ac = t.actor.clone();
|
||||
let boot_account = Arc::clone(t.account());
|
||||
|
|
|
@ -87,7 +87,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
tracing::trace!("startup");
|
||||
|
||||
if config.debt_reporter {
|
||||
syndicate::actor::start_debt_reporter();
|
||||
Actor::new().boot(syndicate::name!("debt-reporter"), |t| {
|
||||
t.state.linked_task(syndicate::name!("tick"), async {
|
||||
let mut timer = tokio::time::interval(core::time::Duration::from_secs(1));
|
||||
loop {
|
||||
timer.tick().await;
|
||||
for (id, (name, debt)) in syndicate::actor::ACCOUNTS.read().unwrap().iter() {
|
||||
let _enter = name.enter();
|
||||
tracing::info!(id, debt = debug(
|
||||
debt.load(std::sync::atomic::Ordering::Relaxed)));
|
||||
}
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
let ds = Cap::new(&Actor::create_and_start(syndicate::name!("dataspace"), Dataspace::new()));
|
||||
|
|
|
@ -376,23 +376,6 @@ preserves_schema::support::lazy_static! {
|
|||
RwLock::new(Map::new());
|
||||
}
|
||||
|
||||
/// Starts a "debt reporter" actor which periodically logs information about active [`Account`]s.
|
||||
pub fn start_debt_reporter() {
|
||||
Actor::new().boot(crate::name!("debt-reporter"), |t| {
|
||||
t.state.linked_task(crate::name!("tick"), async {
|
||||
let mut timer = tokio::time::interval(core::time::Duration::from_secs(1));
|
||||
loop {
|
||||
timer.tick().await;
|
||||
for (id, (name, debt)) in ACCOUNTS.read().unwrap().iter() {
|
||||
let _enter = name.enter();
|
||||
tracing::info!(id, debt = debug(debt.load(Ordering::Relaxed)));
|
||||
}
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
impl TryFrom<&AnyValue> for Synced {
|
||||
type Error = ParseError;
|
||||
fn try_from(value: &AnyValue) -> Result<Self, Self::Error> {
|
||||
|
|
Loading…
Reference in New Issue