Skip to content

Commit

Permalink
adding doc strings, more consistent code style
Browse files Browse the repository at this point in the history
  • Loading branch information
laroque committed Jan 14, 2020
1 parent 5779cae commit efc30a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
38 changes: 22 additions & 16 deletions module_bindings/dripline_core/message_pybind.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef DRIPLINE_PYBIND_MESSAGE
#define DRIPLINE_PYBIND_MESSAGE

#include "binding_helpers.hh"

#include "message.hh"
#include "message_trampoline.hh"

Expand Down Expand Up @@ -29,10 +31,10 @@ namespace dripline_pybind
message
********/
all_items.push_back( "Message" );
pybind11::class_< dripline::message, message_trampoline, std::shared_ptr< dripline::message > > message( mod, "Message" );
pybind11::class_< dripline::message, message_trampoline, std::shared_ptr< dripline::message > > message( mod, "Message", "base class for all dripline messages" );

// internal types
pybind11::enum_< dripline::message::encoding >( message, "encoding" )
pybind11::enum_< dripline::message::encoding >( message, "encoding", "mime-type of message encoding" )
.value( "json", dripline::message::encoding::json )
;

Expand Down Expand Up @@ -78,26 +80,22 @@ namespace dripline_pybind
.def( "create_amqp_messages",
&dripline::message::create_amqp_messages,
"From message object to AMQP",
pybind11::call_guard< pybind11::scoped_ostream_redirect,
pybind11::scoped_estream_redirect >()
DL_BIND_CALL_GUARD_STREAMS
)
.def( "encode_message_body",
&dripline::message::encode_message_body,
"From message object to string",
pybind11::call_guard< pybind11::scoped_ostream_redirect,
pybind11::scoped_estream_redirect >()
DL_BIND_CALL_GUARD_STREAMS
)
.def( "derived_modify_amqp_message",
&_message::derived_modify_amqp_message,
"derived_modify_amqp_message function",
pybind11::call_guard< pybind11::scoped_ostream_redirect,
pybind11::scoped_estream_redirect >()
DL_BIND_CALL_GUARD_STREAMS
)
.def( "derived_modify_message_param",
&_message::derived_modify_message_param,
"derived_modify_amqp_message function",
pybind11::call_guard< pybind11::scoped_ostream_redirect,
pybind11::scoped_estream_redirect >()
DL_BIND_CALL_GUARD_STREAMS
)

.def( "encode_full_message", [](const dripline::message& a_message){ return a_message.encode_full_message(4000); } )
Expand All @@ -107,7 +105,8 @@ namespace dripline_pybind
msg_request
************/
all_items.push_back( "MsgRequest" );
pybind11::class_< dripline::msg_request, msg_request_trampoline, std::shared_ptr< dripline::msg_request > >( mod, "MsgRequest", message )
pybind11::class_< dripline::msg_request, msg_request_trampoline, std::shared_ptr< dripline::msg_request >
>( mod, "MsgRequest", message, "dripline messages containing a request to be sent to an endpoint" )
// constructor(s)
.def( pybind11::init< >() )
// properties
Expand Down Expand Up @@ -139,7 +138,8 @@ namespace dripline_pybind
pybind11::arg( "routing_key" ) = "",
pybind11::arg( "specifier" ) = "",
pybind11::arg( "reply_to" ) = "",
pybind11::arg( "encoding" ) = dripline::message::encoding::json
pybind11::arg( "encoding" ) = dripline::message::encoding::json,
"create and populate a new MsgRequest instance"
)
.def( "reply",
[](dripline::request_ptr_t a_req,
Expand All @@ -150,14 +150,16 @@ namespace dripline_pybind
pybind11::arg( "return_code" ) = 0,
pybind11::arg( "return_message" ) = "",
pybind11::arg_v( "payload", scarab::param(), "scarab::param()" )
"construct and send a reply message in response to this request"
)
;

/************
msg_reply
************/
all_items.push_back( "MsgReply" );
pybind11::class_< dripline::msg_reply, msg_reply_trampoline, std::shared_ptr< dripline::msg_reply > >( mod, "MsgReply", message )
pybind11::class_< dripline::msg_reply, msg_reply_trampoline, std::shared_ptr< dripline::msg_reply >
>( mod, "MsgReply", message, "dripline messages containing a reply to a previously received request" )
// constructor(s)
.def( pybind11::init< >() )

Expand All @@ -184,7 +186,8 @@ namespace dripline_pybind
pybind11::arg( "payload" ) = scarab::param(),
pybind11::arg( "routing_key" ) = "",
pybind11::arg( "specifier" ) = "",
pybind11::arg( "encoding" ) = dripline::message::encoding::json
pybind11::arg( "encoding" ) = dripline::message::encoding::json,
"create and populate a new MsgReply instance"
)
.def_static( "create",
[](unsigned a_retcode_value,
Expand All @@ -196,14 +199,16 @@ namespace dripline_pybind
pybind11::arg( "return_message" ) = "",
pybind11::arg( "payload" ) = scarab::param(),
pybind11::arg( "msg_request" ) = dripline::message::encoding::json
"create and populate a new MsgReply instance"
)
;

/***********
msg_alert
************/
all_items.push_back( "MsgAlert" );
pybind11::class_< dripline::msg_alert, msg_alert_trampoline, std::shared_ptr< dripline::msg_alert > >( mod, "MsgAlert", message )
pybind11::class_< dripline::msg_alert, msg_alert_trampoline, std::shared_ptr< dripline::msg_alert >
>( mod, "MsgAlert", message, "dripline message containing alert information" )
// constructor(s)
.def( pybind11::init< >() )

Expand All @@ -217,7 +222,8 @@ namespace dripline_pybind
pybind11::arg( "payload" ) = scarab::param(),
pybind11::arg( "routing_key" ) = "",
pybind11::arg( "specifier" ) = "",
pybind11::arg( "encoding" ) = dripline::message::encoding::json
pybind11::arg( "encoding" ) = dripline::message::encoding::json,
"create and populate a new MsgAlert instance"
)
;

Expand Down
29 changes: 16 additions & 13 deletions module_bindings/dripline_core/scheduler_pybind.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@ namespace dripline_pybind
//TODO: does it make sense to provide access to the events map? That will require wrapping the stuct they get stored into.

.def( "schedule",
(int (dripline::scheduler<executor_t, clock_t>::*)(executable_t, clock_t::time_point)) &dripline::scheduler<executor_t, clock_t>::schedule,
pybind11::arg( "executable" ),
pybind11::arg( "time" ),
"schedule execution of executable at specified future time"
)
(int (dripline::scheduler<executor_t, clock_t>::*)(executable_t, clock_t::time_point)) &dripline::scheduler<executor_t, clock_t>::schedule,
pybind11::arg( "executable" ),
pybind11::arg( "time" ),
"schedule execution of executable at specified future time")
.def( "schedule",
(int (dripline::scheduler<executor_t, clock_t>::*)(executable_t, clock_t::duration, clock_t::time_point)) &dripline::scheduler<executor_t, clock_t>::schedule,
pybind11::arg( "executable" ),
pybind11::arg( "interval" ),
pybind11::arg_v( "time", clock_t::now(), "now()" ),
"schedule recurring execution of [executable] every [interval], starting at specified future [time]"
)
.def( "unschedule", &dripline::scheduler<executor_t, clock_t>::unschedule, pybind11::arg( "id" ), "Cancel a scheduled function call by its id" )
.def( "execute", &dripline::scheduler<executor_t, clock_t>::execute, "Start the timing thread which executes scheduled actions" )
(int (dripline::scheduler<executor_t, clock_t>::*)(executable_t, clock_t::duration, clock_t::time_point)) &dripline::scheduler<executor_t, clock_t>::schedule,
pybind11::arg( "executable" ),
pybind11::arg( "interval" ),
pybind11::arg_v( "time", clock_t::now(), "now()" ),
"schedule recurring execution of [executable] every [interval], starting at specified future [time]")
.def( "unschedule",
&dripline::scheduler<executor_t, clock_t>::unschedule,
pybind11::arg( "id" ),
"Cancel a scheduled function call by its id" )
.def( "execute",
&dripline::scheduler<executor_t, clock_t>::execute,
"Start the timing thread which executes scheduled actions" )
;

return all_items;
Expand Down

0 comments on commit efc30a4

Please sign in to comment.