8 #define DRIPLINE_API_EXPORTS 19 LOGGER(
dlog,
"hub" );
22 hub::hub(
const scarab::param_node& a_config,
const string& a_queue_name,
const std::string& a_broker_address,
unsigned a_port,
const std::string& a_auth_file,
const bool a_make_connection) :
24 service( a_config, a_queue_name, a_broker_address, a_port, a_auth_file, a_make_connection ),
39 LDEBUG(
dlog,
"Set RUN handler" );
46 LDEBUG(
dlog,
"Set GET handler for <" << a_key <<
">" );
53 LDEBUG(
dlog,
"Set SET handler for <" << a_key <<
">" );
60 LDEBUG(
dlog,
"Set CMD handler for <" << a_key <<
">" );
68 LWARN(
dlog,
"GET handler <" << a_key <<
"> was not present; nothing was removed" );
72 LDEBUG(
dlog,
"GET handler <" << a_key <<
"> was removed" );
81 LWARN(
dlog,
"SET handler <" << a_key <<
"> was not present; nothing was removed" );
85 LDEBUG(
dlog,
"SET handler <" << a_key <<
"> was removed" );
94 LWARN(
dlog,
"CMD handler <" << a_key <<
"> was not present; nothing was removed" );
98 LDEBUG(
dlog,
"CMD handler <" << a_key <<
"> was removed" );
110 std::string t_query_type = a_request->parsed_specifier().front();
111 a_request->parsed_specifier().pop_front();
117 catch( std::out_of_range& e )
119 LWARN(
dlog,
"GET query type <" << t_query_type <<
"> was not understood (" << e.what() <<
")" );
120 return a_request->reply(
dl_service_error_bad_payload(),
"Unrecognized query type or no query type provided: <" + t_query_type +
">" );;
126 std::string t_set_type = a_request->parsed_specifier().front();
127 a_request->parsed_specifier().pop_front();
133 catch( std::out_of_range& e )
135 LWARN(
dlog,
"SET request <" << t_set_type <<
"> not understood (" << e.what() <<
")" );
136 return a_request->reply(
dl_service_error_bad_payload(),
"Unrecognized set request type or no set request type provided: <" + t_set_type +
">" );
144 std::string t_instruction = a_request->parsed_specifier().front();
145 a_request->parsed_specifier().pop_front();
151 catch( std::out_of_range& e )
153 LWARN(
dlog,
"CMD instruction <" << t_instruction <<
"> not understood (" << e.what() <<
")" );
handler_funcs_t f_get_handlers
std::function< reply_ptr_t(const dripline::request_ptr_t) > handler_func_t
void remove_get_handler(const std::string &a_key)
Removes a get request handler function.
void register_cmd_handler(const std::string &a_key, const handler_func_t &a_func)
Sets a command request handler function.
hub(const scarab::param_node &a_config=scarab::param_node(), const std::string &a_queue_name="", const std::string &a_broker_address="", unsigned a_port=0, const std::string &a_auth_file="", const bool a_make_connection=true)
std::shared_ptr< msg_request > request_ptr_t
void register_get_handler(const std::string &a_key, const handler_func_t &a_func)
Sets a get request handler function.
virtual reply_ptr_t do_cmd_request(const request_ptr_t a_request)
Consumer of Dripline messages on a particular queue.
handler_func_t f_run_handler
virtual reply_ptr_t do_set_request(const request_ptr_t a_request)
virtual reply_ptr_t do_run_request(const request_ptr_t a_request)
static scarab::logger dlog("agent")
handler_funcs_t f_set_handlers
void register_set_handler(const std::string &a_key, const handler_func_t &a_func)
Sets a set request handler function.
std::shared_ptr< msg_reply > reply_ptr_t
void remove_cmd_handler(const std::string &a_key)
Removes a command request handler function.
void set_run_handler(const handler_func_t &a_func)
Sets the run request handler function.
virtual reply_ptr_t do_get_request(const request_ptr_t a_request)
handler_funcs_t f_cmd_handlers
void remove_set_handler(const std::string &a_key)
Removes a set request handler function.