diff --git a/ci-broker.md b/ci-broker.md index 050948e3..22f5e3c1 100644 --- a/ci-broker.md +++ b/ci-broker.md @@ -232,10 +232,9 @@ when I run bash radenv.sh bash setup-node.sh given an installed synthetic-events given file refsfetched.json -given file shutdown.json given file set-rid when I run env HOME=../homedir python3 set-rid refsfetched.json testy -when I run synthetic-events synt.sock refsfetched.json shutdown.json --log log.txt +when I run synthetic-events synt.sock refsfetched.json --log log.txt given an installed cib given a directory reports @@ -245,9 +244,9 @@ when I run chmod +x adapter.sh when I try to run bash radenv.sh RAD_SOCKET=synt.sock cib --config broker.yaml insert then command is successful -when I run cibtool --db ci-broker.db event shutdown given an installed cibtool +when I run cibtool --db ci-broker.db event shutdown when I run cibtool --db ci-broker.db event list when I run cibtool --db ci-broker.db run list @@ -281,10 +280,9 @@ when I run bash radenv.sh bash setup-node.sh given an installed synthetic-events given file refsfetched.json -given file shutdown.json given file set-rid when I run env HOME=../homedir python3 set-rid refsfetched.json testy -when I run synthetic-events synt.sock refsfetched.json shutdown.json --log log.txt +when I run synthetic-events synt.sock refsfetched.json --log log.txt given file adapter.sh from adapter-with-url.sh when I run chmod +x adapter.sh @@ -383,7 +381,7 @@ given an installed synthetic-events when I run synthetic-events synt.sock --log log.txt given file broker.yaml when I try to run bash radenv.sh RAD_SOCKET=synt.sock cib --config broker.yaml insert -then stderr contains "connection to the node control socket broke" +then command is successful ~~~ @@ -409,11 +407,13 @@ when I run bash radenv.sh bash setup-node.sh given an installed cib given an installed synthetic-events -given file shutdown.json given file broker.yaml -when I run synthetic-events synt.sock shutdown.json --log synt.log +when I run synthetic-events synt.sock --log synt.log when I try to run bash radenv.sh RAD_SOCKET=synt.sock cib --config broker.yaml insert +when I run cat synt.log then command is successful +when I run cibtool --db ci-broker.db run list +then stdout is exactly "" ~~~ @@ -574,8 +574,7 @@ given an installed cib given an installed synthetic-events given file refsfetched.json -given file shutdown.json -when I run synthetic-events synt.sock refsfetched.json shutdown.json --log synt.log +when I run synthetic-events synt.sock refsfetched.json --log synt.log given file broker.yaml when I try to run bash radenv.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert @@ -604,8 +603,7 @@ given an installed cib given an installed synthetic-events given file refsfetched.json -given file shutdown.json -when I run synthetic-events synt.sock refsfetched.json shutdown.json --log synt.log --repeat 1000 +when I run synthetic-events synt.sock refsfetched.json --log synt.log --repeat 1000 given file broker.yaml when I try to run bash radenv.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert @@ -635,8 +633,7 @@ given an installed cib given an installed synthetic-events given file refsfetched.json -given file shutdown.json -when I run synthetic-events synt.sock refsfetched.json shutdown.json --log synt.log +when I run synthetic-events synt.sock refsfetched.json --log synt.log given file broker.yaml from broker-allow-nothing.yaml when I try to run bash radenv.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert diff --git a/src/event.rs b/src/event.rs index 84346f31..bd0fc7dc 100644 --- a/src/event.rs +++ b/src/event.rs @@ -111,10 +111,6 @@ impl NodeEventSource { if let Some(event) = self.events.next() { trace!("got event from local node: {event:#?}"); match event { - Ok(ref event) if Self::is_shutdown_request(event) => { - info!("got shutdown request from node control socket"); - return Ok(vec![BrokerEvent::shutdown()]); - } Ok(event) => { trace!("got node event {:#?}", event); let mut result = vec![]; @@ -140,21 +136,10 @@ impl NodeEventSource { } } else { trace!("no more node events from control socket: iterator ended"); - return Err(NodeEventError::BrokenConnection); + return Ok(vec![]); } } } - - fn is_shutdown_request(event: &Event) -> bool { - if let Event::RefsFetched { updated, .. } = event { - if let Some(RefUpdate::Skipped { name, .. }) = updated.first() { - if name == &RefString::try_from("shutdown").expect("create name") { - return true; - } - } - } - false - } } /// Possible errors from accessing the local Radicle node. diff --git a/src/queueadd.rs b/src/queueadd.rs index 7bee710f..c8f16469 100644 --- a/src/queueadd.rs +++ b/src/queueadd.rs @@ -6,7 +6,7 @@ use log::{debug, info}; use crate::{ db::{Db, DbError}, - event::{BrokerEvent, EventFilter, NodeEventError, NodeEventSource}, + event::{EventFilter, NodeEventError, NodeEventSource}, }; #[derive(Default)] @@ -60,14 +60,14 @@ impl QueueAdder { // event from the node. 'event_loop: loop { debug!("waiting for event from node"); - for e in source.event()? { - debug!("got event {e:#?}"); - match e { - BrokerEvent::Shutdown => break 'event_loop, - BrokerEvent::RefChanged { .. } => { - info!("insert broker event into queue: {e:#?}"); - self.db.push_queued_event(e)?; - } + let events = source.event()?; + if events.is_empty() { + break 'event_loop; + } else { + for e in events { + debug!("got event {e:#?}"); + info!("insert broker event into queue: {e:#?}"); + self.db.push_queued_event(e)?; } } }