8 #define DRIPLINE_API_EXPORTS
22 hub::hub(
const scarab::param_node& a_config,
const scarab::authentication& a_auth,
const bool a_make_connection) :
24 service( a_config, a_auth, a_make_connection ),
33 cancelable::operator=( std::move(a_orig) );
47 LDEBUG(
dlog,
"Set RUN handler" );
54 LDEBUG(
dlog,
"Set GET handler for <" << a_key <<
">" );
61 LDEBUG(
dlog,
"Set SET handler for <" << a_key <<
">" );
68 LDEBUG(
dlog,
"Set CMD handler for <" << a_key <<
">" );
76 LWARN(
dlog,
"GET handler <" << a_key <<
"> was not present; nothing was removed" );
80 LDEBUG(
dlog,
"GET handler <" << a_key <<
"> was removed" );
89 LWARN(
dlog,
"SET handler <" << a_key <<
"> was not present; nothing was removed" );
93 LDEBUG(
dlog,
"SET handler <" << a_key <<
"> was removed" );
102 LWARN(
dlog,
"CMD handler <" << a_key <<
"> was not present; nothing was removed" );
106 LDEBUG(
dlog,
"CMD handler <" << a_key <<
"> was removed" );
118 std::string t_query_type = a_request->parsed_specifier().front();
119 a_request->parsed_specifier().pop_front();
125 catch( std::out_of_range& e )
127 LWARN(
dlog,
"GET query type <" << t_query_type <<
"> was not understood (" << e.what() <<
")" );
128 return a_request->reply(
dl_service_error_bad_payload(),
"Unrecognized query type or no query type provided: <" + t_query_type +
">" );;
134 std::string t_set_type = a_request->parsed_specifier().front();
135 a_request->parsed_specifier().pop_front();
141 catch( std::out_of_range& e )
143 LWARN(
dlog,
"SET request <" << t_set_type <<
"> not understood (" << e.what() <<
")" );
144 return a_request->reply(
dl_service_error_bad_payload(),
"Unrecognized set request type or no set request type provided: <" + t_set_type +
">" );
152 std::string t_instruction = a_request->parsed_specifier().front();
153 a_request->parsed_specifier().pop_front();
159 catch( std::out_of_range& e )
161 LWARN(
dlog,
"CMD instruction <" << t_instruction <<
"> not understood (" << e.what() <<
")" );
Service class aimed at adding a Dripline API to an existing codebase.
void register_cmd_handler(const std::string &a_key, const handler_func_t &a_func)
Sets a command request handler function.
void remove_set_handler(const std::string &a_key)
Removes a set request handler function.
virtual reply_ptr_t do_cmd_request(const request_ptr_t a_request)
void register_set_handler(const std::string &a_key, const handler_func_t &a_func)
Sets a set request handler function.
handler_funcs_t f_set_handlers
void remove_cmd_handler(const std::string &a_key)
Removes a command request handler function.
void register_get_handler(const std::string &a_key, const handler_func_t &a_func)
Sets a get request handler function.
std::function< reply_ptr_t(const dripline::request_ptr_t) > handler_func_t
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
handler_funcs_t f_get_handlers
void remove_get_handler(const std::string &a_key)
Removes a get request handler function.
virtual reply_ptr_t do_run_request(const request_ptr_t a_request)
handler_func_t f_run_handler
virtual reply_ptr_t do_set_request(const request_ptr_t a_request)
hub & operator=(const hub &)=delete
hub(const scarab::param_node &a_config, const scarab::authentication &a_auth, const bool a_make_connection=true)
Primary unit of software that connects to a broker and typically provides an interface with an instru...
service & operator=(const service &)=delete
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