From e94bd2bb70d8d76352d90ad0121d29bcf5829c04 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Tue, 18 Feb 2025 17:21:25 -0800 Subject: [PATCH 01/13] Updated sandfly (on feature branch) --- sandfly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandfly b/sandfly index 0ead4ce..b46bbaa 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit 0ead4ce3b48fb5b5274b6c65d37b6fcee4e1fcd9 +Subproject commit b46bbaa440d653b37d96e60a63e7f258f8df58a8 From be186bc99129379cb70849833de16e7abae4a294 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Tue, 18 Feb 2025 17:21:38 -0800 Subject: [PATCH 02/13] Add slack_relayer --- source/utility/CMakeLists.txt | 2 ++ source/utility/slack_relayer.cc | 54 +++++++++++++++++++++++++++++++++ source/utility/slack_relayer.hh | 40 ++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 source/utility/slack_relayer.cc create mode 100644 source/utility/slack_relayer.hh diff --git a/source/utility/CMakeLists.txt b/source/utility/CMakeLists.txt index 18daa4f..b8b0886 100644 --- a/source/utility/CMakeLists.txt +++ b/source/utility/CMakeLists.txt @@ -6,9 +6,11 @@ set( headers byte_swap.hh psyllid_error.hh psyllid_version.hh + slack_relayer.hh ) set( sources psyllid_error.cc + slack_relayer.cc ) configure_file( psyllid_version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/psyllid_version.cc ) diff --git a/source/utility/slack_relayer.cc b/source/utility/slack_relayer.cc new file mode 100644 index 0000000..1778cc1 --- /dev/null +++ b/source/utility/slack_relayer.cc @@ -0,0 +1,54 @@ +/* + * slack_relayer.cc + * + * Created on: Feb 18, 2025 + * Author: N.S. Oblath + */ + +#include "slack_relayer.hh" + +#include "param.hh" + +namespace psyllid +{ + + slack_relayer::slack_relayer( const scarab::param_node& a_config, const scarab::authentication& a_auth ) : + sandfly::message_relayer( a_config, a_auth ) + {} + + + void slack_relayer::send_notice( const std::string& a_msg_text ) const + { + send_to_slack( a_msg_text, "status_message.notice." ); + return; + } + + void slack_relayer::send_warn( const std::string& a_msg_text ) const + { + send_to_slack( a_msg_text, "status_message.warning." ); + return; + } + + void slack_relayer::send_error( const std::string& a_msg_text ) const + { + send_to_slack( a_msg_text, "status_message.error." ); + return; + } + + void slack_relayer::send_critical( const std::string& a_msg_text ) const + { + send_to_slack( a_msg_text, "status_message.critical." ); + return; + } + + void slack_relayer::send_to_slack( const std::string& a_msg_text, const std::string& a_rk_root ) const + { + if( ! f_use_relayer ) return; + scarab::param_ptr_t t_msg_ptr( new scarab::param_node() ); + scarab::param_node& t_msg = t_msg_ptr->as_node(); + t_msg.add( "message", scarab::param_value( a_msg_text ) ); + send_async( dripline::msg_alert::create( std::move(t_msg_ptr), a_rk_root + f_queue_name ) ); + return; + } + +} /* namespace psyllid */ diff --git a/source/utility/slack_relayer.hh b/source/utility/slack_relayer.hh new file mode 100644 index 0000000..a7dc981 --- /dev/null +++ b/source/utility/slack_relayer.hh @@ -0,0 +1,40 @@ +/* + * slack_relayer.hh + * + * Created on: Feb 18, 2025 + * Author: N.S. Oblath + */ + +#ifndef PSYLLID_SLACK_RELAYER_HH_ +#define PSYLLID_SLACK_RELAYER_HH_ + +#include "message_relayer.hh" + + +namespace psyllid +{ + + class slack_relayer : public sandfly::message_relayer + { + public: + slack_relayer( const scarab::param_node& a_config, const scarab::authentication& a_auth ); + slack_relayer( const slack_relayer& ) = delete; + slack_relayer( slack_relayer&& ) = default; + virtual ~slack_relayer() = default; + + slack_relayer& operator=( const slack_relayer& ) = delete; + slack_relayer& operator=( slack_relayer&& ) = default; + + public: + void send_notice( const std::string& a_msg_text ) const override; + void send_warn( const std::string& a_msg_text ) const override; + void send_error( const std::string& a_msg_text ) const override; + void send_critical( const std::string& a_msg_text ) const override; + + protected: + void send_to_slack( const std::string& a_msg_text, const std::string& a_rk_root ) const; + }; + +} /* namespace psyllid */ + +#endif /* PSYLLID_SLACK_RELAYER_HH_ */ From 95d232d8b5cb0718f0897b6e43fc3d04a40f4cf9 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Tue, 18 Feb 2025 17:22:41 -0800 Subject: [PATCH 03/13] Adapt to refactoring of message_relayer --- source/applications/psyllid.cc | 5 ++++- source/control/daq_control.cc | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/applications/psyllid.cc b/source/applications/psyllid.cc index 6b14642..8cc72ea 100644 --- a/source/applications/psyllid.cc +++ b/source/applications/psyllid.cc @@ -12,6 +12,7 @@ #include "conductor.hh" #include "sandfly_error.hh" #include "server_config.hh" +#include "slack_relayer.hh" #include "application.hh" #include "logger.hh" @@ -52,7 +53,9 @@ int main( int argc, char** argv ) auto t_cwrap = scarab::wrap_cancelable( the_conductor ); t_sig_hand.add_cancelable( t_cwrap ); - the_conductor.execute( the_main.primary_config(), the_main.auth() ); + the_conductor.execute( the_main.primary_config(), the_main.auth(), +// std::shared_ptr< message_relayer >(new slack_relayer( the_main.primary_config(), the_main.auth() )) ); + std::make_shared< slack_relayer >(the_main.primary_config(), the_main.auth()) ); } ); // Command line options diff --git a/source/control/daq_control.cc b/source/control/daq_control.cc index 6be2919..2c4c8c5 100644 --- a/source/control/daq_control.cc +++ b/source/control/daq_control.cc @@ -59,7 +59,7 @@ namespace psyllid catch( std::exception& e ) { LERROR( plog, "Unable to start files: " << e.what() ); - f_msg_relay->slack_error( std::string("Unable to start files: ") + e.what() ); + f_msg_relay->send_error( std::string("Unable to start files: ") + e.what() ); set_status( status::error ); LDEBUG( plog, "Canceling midge" ); if( f_midge_pkg.have_lock() ) f_midge_pkg->cancel(); @@ -81,7 +81,7 @@ namespace psyllid catch( std::exception& e ) { LERROR( plog, "Unable to finish files: " << e.what() ); - f_msg_relay->slack_error( std::string("Unable to finish files: ") + e.what() ); + f_msg_relay->send_error( std::string("Unable to finish files: ") + e.what() ); set_status( status::error ); LDEBUG( plog, "Canceling midge" ); if( f_midge_pkg.have_lock() ) f_midge_pkg->cancel(); From 2c31516ca50f7c895f2aafe64ae0b24d19992425 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Tue, 18 Feb 2025 17:41:01 -0800 Subject: [PATCH 04/13] Sandfly update --- sandfly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandfly b/sandfly index b46bbaa..c54f6c0 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit b46bbaa440d653b37d96e60a63e7f258f8df58a8 +Subproject commit c54f6c0e7b6dc22ccd8bd1ae2b0860faba54e4be From 67b3a16702188b268f4fa79f1aee3226584de66b Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 11:11:13 -0800 Subject: [PATCH 05/13] Allow slack_relayer to send a more complex payload --- sandfly | 2 +- source/utility/slack_relayer.cc | 33 ++++++++++++++++++++++++++++++++- source/utility/slack_relayer.hh | 7 +++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/sandfly b/sandfly index c54f6c0..914c691 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit c54f6c0e7b6dc22ccd8bd1ae2b0860faba54e4be +Subproject commit 914c691b8a91ea69a89c020ef7dafc2205bdf319 diff --git a/source/utility/slack_relayer.cc b/source/utility/slack_relayer.cc index 1778cc1..b008cb6 100644 --- a/source/utility/slack_relayer.cc +++ b/source/utility/slack_relayer.cc @@ -41,13 +41,44 @@ namespace psyllid return; } + void slack_relayer::send_notice( scarab::param_ptr_t&& a_payload ) const + { + send_to_slack( std::move(a_payload), "status_message.notice." ); + return; + } + + void slack_relayer::send_warn( scarab::param_ptr_t&& a_payload ) const + { + send_to_slack( std::move(a_payload), "status_message.warning." ); + return; + } + + void slack_relayer::send_error( scarab::param_ptr_t&& a_payload ) const + { + send_to_slack( std::move(a_payload), "status_message.error." ); + return; + } + + void slack_relayer::send_critical( scarab::param_ptr_t&& a_payload ) const + { + send_to_slack( std::move(a_payload), "status_message.critical." ); + return; + } + void slack_relayer::send_to_slack( const std::string& a_msg_text, const std::string& a_rk_root ) const { if( ! f_use_relayer ) return; scarab::param_ptr_t t_msg_ptr( new scarab::param_node() ); scarab::param_node& t_msg = t_msg_ptr->as_node(); t_msg.add( "message", scarab::param_value( a_msg_text ) ); - send_async( dripline::msg_alert::create( std::move(t_msg_ptr), a_rk_root + f_queue_name ) ); + send_to_slack( std::move(t_msg_ptr), a_rk_root ); + return; + } + + void slack_relayer::send_to_slack( scarab::param_ptr_t&& a_payload, const std::string& a_rk_root ) const + { + if( ! f_use_relayer ) return; + send_async( dripline::msg_alert::create( std::move(a_payload), a_rk_root + f_queue_name ) ); return; } diff --git a/source/utility/slack_relayer.hh b/source/utility/slack_relayer.hh index a7dc981..22b0b24 100644 --- a/source/utility/slack_relayer.hh +++ b/source/utility/slack_relayer.hh @@ -10,6 +10,7 @@ #include "message_relayer.hh" +#include "param_fwd.hh" namespace psyllid { @@ -31,8 +32,14 @@ namespace psyllid void send_error( const std::string& a_msg_text ) const override; void send_critical( const std::string& a_msg_text ) const override; + void send_notice( scarab::param_ptr_t&& a_payload ) const override; + void send_warn( scarab::param_ptr_t&& a_payload ) const override; + void send_error( scarab::param_ptr_t&& a_payload ) const override; + void send_critical( scarab::param_ptr_t&& a_payload ) const override; + protected: void send_to_slack( const std::string& a_msg_text, const std::string& a_rk_root ) const; + void send_to_slack( scarab::param_ptr_t&& a_payload, const std::string& a_rk_root ) const; }; } /* namespace psyllid */ From 8a6e84617d9275798068dfbbb727cf6e629a3052 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 11:22:12 -0800 Subject: [PATCH 06/13] Sandfly update --- sandfly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandfly b/sandfly index 914c691..4775e75 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit 914c691b8a91ea69a89c020ef7dafc2205bdf319 +Subproject commit 4775e7584c37a23f02b91d618d117f21ea20dd06 From 71a690d577d5c4e5705147ae0e398f31a5facb04 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 11:45:01 -0800 Subject: [PATCH 07/13] Use templated conductor::execute() --- sandfly | 2 +- source/applications/psyllid.cc | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sandfly b/sandfly index 4775e75..3bcc25d 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit 4775e7584c37a23f02b91d618d117f21ea20dd06 +Subproject commit 3bcc25dfe2b85652fe73fc8e31020a5ec2b4bcdc diff --git a/source/applications/psyllid.cc b/source/applications/psyllid.cc index 8cc72ea..11f11b2 100644 --- a/source/applications/psyllid.cc +++ b/source/applications/psyllid.cc @@ -42,7 +42,6 @@ int main( int argc, char** argv ) // The application scarab::main_app the_main; conductor the_conductor; - the_conductor.set_rc_creator< daq_control >(); // Default configuration the_main.default_config() = server_config(); @@ -53,9 +52,8 @@ int main( int argc, char** argv ) auto t_cwrap = scarab::wrap_cancelable( the_conductor ); t_sig_hand.add_cancelable( t_cwrap ); - the_conductor.execute( the_main.primary_config(), the_main.auth(), -// std::shared_ptr< message_relayer >(new slack_relayer( the_main.primary_config(), the_main.auth() )) ); - std::make_shared< slack_relayer >(the_main.primary_config(), the_main.auth()) ); + the_conductor.execute< daq_control >( the_main.primary_config(), the_main.auth(), + std::make_shared< slack_relayer >(the_main.primary_config(), the_main.auth()) ); } ); // Command line options From a56a9b06bc991e0c675d5ff55ee2213ddb4a2064 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 15:46:18 -0800 Subject: [PATCH 08/13] No need to set a default auth file anymore --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd05abd..4588671 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,9 +85,6 @@ endif( FFTW_FOUND ) # Boost (1.48 required for container; scarab minimum is 1.46) #find_package( Boost 1.48.0 REQUIRED ) -# Sandfly -add_definitions( -DDRIPLINE_AUTH_FILE=~/.project8_authentications.json ) - # Included external dependencies # Including: tk_spline add_subdirectory( external ) From 23856c334e8b53481a2e51dd76c29748e713b1f7 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 15:46:29 -0800 Subject: [PATCH 09/13] Update sandfly --- sandfly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandfly b/sandfly index 3bcc25d..5874ac1 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit 3bcc25dfe2b85652fe73fc8e31020a5ec2b4bcdc +Subproject commit 5874ac1fbf19ae2e218e1deb42c812f86a5966c5 From 4308604728b73f3563d6f9463c9680fd40be5775 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 15:55:37 -0800 Subject: [PATCH 10/13] Update sandfly and set default name to psyllid --- sandfly | 2 +- source/applications/psyllid.cc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sandfly b/sandfly index 5874ac1..fac12af 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit 5874ac1fbf19ae2e218e1deb42c812f86a5966c5 +Subproject commit fac12afa2f3b88fa8e4aabf5db23de90ccbe47a4 diff --git a/source/applications/psyllid.cc b/source/applications/psyllid.cc index 11f11b2..c74ce24 100644 --- a/source/applications/psyllid.cc +++ b/source/applications/psyllid.cc @@ -44,7 +44,9 @@ int main( int argc, char** argv ) conductor the_conductor; // Default configuration + // Same as sandfly, but change the name the_main.default_config() = server_config(); + the_main.default_config()["name"]() = "psyllid"; // The main execution callback the_main.callback( [&](){ From 6e923def95d33e58e9d2b548f373aaddae442cb9 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 17:08:07 -0800 Subject: [PATCH 11/13] Example config files updated --- examples/eb_fmt_1ch_fpa.yaml | 5 ++--- examples/eb_fmt_1ch_socket.yaml | 7 ++++--- examples/fmt_1ch_fpa.yaml | 7 ++++--- examples/fmt_1ch_socket.yaml | 5 +++-- examples/str_1ch_dataprod.yaml | 7 ++++--- examples/str_1ch_fpa.yaml | 7 ++++--- examples/str_1ch_socket.yaml | 7 ++++--- examples/str_1ch_socket_batch.yaml | 4 +++- examples/str_1ch_socket_custom.yaml | 7 ++++--- examples/str_3ch_fpa.yaml | 7 ++++--- 10 files changed, 36 insertions(+), 27 deletions(-) diff --git a/examples/eb_fmt_1ch_fpa.yaml b/examples/eb_fmt_1ch_fpa.yaml index f8ec241..a45109c 100644 --- a/examples/eb_fmt_1ch_fpa.yaml +++ b/examples/eb_fmt_1ch_fpa.yaml @@ -1,8 +1,7 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +use-relayer: false daq: activate-at-startup: true diff --git a/examples/eb_fmt_1ch_socket.yaml b/examples/eb_fmt_1ch_socket.yaml index b2a6ee1..9fc8d7b 100644 --- a/examples/eb_fmt_1ch_socket.yaml +++ b/examples/eb_fmt_1ch_socket.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/fmt_1ch_fpa.yaml b/examples/fmt_1ch_fpa.yaml index cb89092..ff51bf2 100644 --- a/examples/fmt_1ch_fpa.yaml +++ b/examples/fmt_1ch_fpa.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/fmt_1ch_socket.yaml b/examples/fmt_1ch_socket.yaml index c85c08a..5871d33 100644 --- a/examples/fmt_1ch_socket.yaml +++ b/examples/fmt_1ch_socket.yaml @@ -1,8 +1,9 @@ dripline: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/str_1ch_dataprod.yaml b/examples/str_1ch_dataprod.yaml index a9adb74..d8427f3 100644 --- a/examples/str_1ch_dataprod.yaml +++ b/examples/str_1ch_dataprod.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/str_1ch_fpa.yaml b/examples/str_1ch_fpa.yaml index 30dab0c..ffaf5e5 100644 --- a/examples/str_1ch_fpa.yaml +++ b/examples/str_1ch_fpa.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/str_1ch_socket.yaml b/examples/str_1ch_socket.yaml index 316e865..9b0ee0c 100644 --- a/examples/str_1ch_socket.yaml +++ b/examples/str_1ch_socket.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/str_1ch_socket_batch.yaml b/examples/str_1ch_socket_batch.yaml index 3cbdd82..0ce3406 100644 --- a/examples/str_1ch_socket_batch.yaml +++ b/examples/str_1ch_socket_batch.yaml @@ -1,4 +1,6 @@ -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/str_1ch_socket_custom.yaml b/examples/str_1ch_socket_custom.yaml index af09528..9cabcde 100644 --- a/examples/str_1ch_socket_custom.yaml +++ b/examples/str_1ch_socket_custom.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true diff --git a/examples/str_3ch_fpa.yaml b/examples/str_3ch_fpa.yaml index 9247ce9..38a8838 100644 --- a/examples/str_3ch_fpa.yaml +++ b/examples/str_3ch_fpa.yaml @@ -1,8 +1,9 @@ -dripline: +dripline_mesh: broker: localhost - queue: psyllid -post-to-slack: false +name: psyllid + +use-relayer: false daq: activate-at-startup: true From 59affb4161a7893422f41e4427e4fa7ad7133a4e Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Wed, 19 Feb 2025 17:41:23 -0800 Subject: [PATCH 12/13] Updated sandfly --- sandfly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandfly b/sandfly index fac12af..15a44a5 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit fac12afa2f3b88fa8e4aabf5db23de90ccbe47a4 +Subproject commit 15a44a520373dd999d6adefc4d0816ae14e0e2c7 From 973826f402381819beb5c1818dd13552abacd99c Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Thu, 13 Mar 2025 17:25:02 -0700 Subject: [PATCH 13/13] Sandfly upgraded to v0.6.0 --- sandfly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandfly b/sandfly index 15a44a5..bca32da 160000 --- a/sandfly +++ b/sandfly @@ -1 +1 @@ -Subproject commit 15a44a520373dd999d6adefc4d0816ae14e0e2c7 +Subproject commit bca32da76947e82ce104463dfef02d3f171a8eac