8 #define DRIPLINE_EXAMPLES_API_EXPORTS
17 #include "signal_handler.hh"
22 LOGGER(
dlog,
"simple_service" )
27 simple_service::simple_service(
const scarab::param_node& a_config,
const scarab::authentication& a_auth ) :
40 auto t_cwrap = scarab::wrap_cancelable( *
this );
41 scarab::signal_handler::add_cancelable( t_cwrap );
47 catch( std::exception& e )
49 LERROR(
dlog,
"Exception caught: " << e.what() );
50 LERROR(
dlog,
"Exiting service" );
52 scarab::signal_handler::cancel_all( f_return );
55 if( scarab::signal_handler::get_exited() )
57 f_return = scarab::signal_handler::get_return_code();
65 if( a_request->parsed_specifier().empty() )
70 std::string t_specifier = a_request->parsed_specifier().front();
71 a_request->parsed_specifier().pop_front();
73 if( t_specifier ==
"echo" )
76 LDEBUG(
dlog,
"Echoing payload: \n" << a_request->payload() );
77 t_reply->set_payload( a_request->payload().clone() );
80 else if( t_specifier ==
"error" )
82 throw std::runtime_error(
"An error occurred in the endpoint! (Note: this is a test, this is only a test)" );
Primary unit of software that connects to a broker and typically provides an interface with an instru...
virtual reply_ptr_t do_cmd_request(const request_ptr_t a_request)
virtual ~simple_service()
std::shared_ptr< msg_reply > reply_ptr_t
static ::scarab::logger_type< ::scarab::spd_initializer_async_stdout_color_mt > dlog("agent", __FILE_NAME__, __LINE__)
std::shared_ptr< msg_request > request_ptr_t
static ::scarab::logger_type< ::scarab::spd_initializer_async_stdout_color_mt > dlog("simple_service", __FILE_NAME__, __LINE__)
virtual unsigned rc_value() const