Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
refactor: drop BrokerEventSource::node_event, use NodeEventSource
Lars Wirzenius committed 1 year ago
commit 50e82fc41177cc83b71e83df1135e337bb318df8
parent 5017e2cc77888775e1922d25ebeb4d960663e9e3
3 files changed +4 -22
modified src/bin/cibtool.rs
@@ -314,10 +314,10 @@ enum CibToolError {
    NoDb,

    #[error("failed to subscribe to node events")]
-
    EventSubscribe(#[source] radicle_ci_broker::event::BrokerEventError),
+
    EventSubscribe(#[source] radicle_ci_broker::node_event_source::NodeEventError),

    #[error("failed to get next node event")]
-
    GetNodeEvent(#[source] radicle_ci_broker::event::BrokerEventError),
+
    GetNodeEvent(#[source] radicle_ci_broker::node_event_source::NodeEventError),

    #[error("failed to create file for node events: {0}")]
    CreateEventsFile(PathBuf, #[source] std::io::Error),
modified src/bin/cibtoolcmd/event.rs
@@ -1,6 +1,6 @@
use std::io::Write;

-
use radicle_ci_broker::event::{BrokerEventSource, EventFilter};
+
use radicle_ci_broker::{event::EventFilter, node_event_source::NodeEventSource};

use super::*;

@@ -312,7 +312,7 @@ pub struct RecordEvents {
impl Leaf for RecordEvents {
    fn run(&self, _args: &Args) -> Result<(), CibToolError> {
        let profile = util::load_profile()?;
-
        let mut source = BrokerEventSource::new(&profile).map_err(CibToolError::EventSubscribe)?;
+
        let mut source = NodeEventSource::new(&profile).map_err(CibToolError::EventSubscribe)?;
        let mut file = if let Some(filename) = &self.output {
            Some(
                std::fs::File::create(filename)
modified src/event.rs
@@ -81,24 +81,6 @@ impl BrokerEventSource {
        Ok(true)
    }

-
    /// Get the next node event from an event source, without
-
    /// filtering. This will block until there is an event, or until
-
    /// there will be no more events from this source, or there's an
-
    /// error.
-
    pub fn node_event(&mut self) -> Result<Option<Event>, BrokerEventError> {
-
        match self.source.node_event() {
-
            Err(NodeEventError::BrokenConnection) => {
-
                logger::event_disconnected();
-
                Err(BrokerEventError::BrokenConnection)
-
            }
-
            Err(err) => {
-
                logger::error("error reading event from node", &err);
-
                Err(BrokerEventError::NodeEventError(err))
-
            }
-
            Ok(maybe_event) => Ok(maybe_event),
-
        }
-
    }
-

    /// Get the allowed next event from an event source. This will
    /// block until there is an allowed event, or until there will be
    /// no more events from this source, or there's an error.