"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "server/re/include/irods_re_plugin.hpp" between
irods-4.2.5.tar.gz and irods-4.2.6.tar.gz

About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.

irods_re_plugin.hpp  (irods-4.2.5):irods_re_plugin.hpp  (irods-4.2.6)
skipping to change at line 21 skipping to change at line 21
#include <list> #include <list>
#include <vector> #include <vector>
#include <utility> #include <utility>
#include <functional> #include <functional>
#include <map> #include <map>
#include <memory> #include <memory>
#include <initializer_list> #include <initializer_list>
#include <boost/any.hpp> #include <boost/any.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
namespace irods { namespace irods {
/* How to use /* How to use
* Get rei and set necessary fields * Get rei and set necessary fields
ruleExecInfo_t rei; ruleExecInfo_t rei;
memset( ( char* )&rei, 0, sizeof( ruleExecInfo_t ) ); memset( ( char* )&rei, 0, sizeof( ruleExecInfo_t ) );
rei.rsComm = _comm; rei.rsComm = _comm;
* Create rule_engine_context_manager * Create rule_engine_context_manager
skipping to change at line 321 skipping to change at line 322
bool execOnce = false; bool execOnce = false;
std::function<error()> op = [&execOnce, &_ps..., &_operation] () { std::function<error()> op = [&execOnce, &_ps..., &_operation] () {
if(execOnce) { if(execOnce) {
return ERROR(RE_TYPE_ERROR, "cannot execute operation more t han once with client supplied arguments"); return ERROR(RE_TYPE_ERROR, "cannot execute operation more t han once with client supplied arguments");
} else { } else {
execOnce = true; execOnce = true;
return _operation(std::forward<As>(_ps)...); return _operation(std::forward<As>(_ps)...);
} }
}; };
error err = op(); auto err = op();
if (!err.ok()) { return !err.ok() ? PASS(err) : err;
return PASS(err);
}
return SUCCESS();
} }
protected: protected:
std::shared_ptr<rule_engine_context_manager<T,C,Audit> >re_mgr_; std::shared_ptr<rule_engine_context_manager<T,C,Audit> >re_mgr_;
}; // class dynamic_operation_execution_manager }; // class dynamic_operation_execution_manager
// DONE // DONE
template<typename T> template<typename T>
struct re_pack_inp final { struct re_pack_inp final {
std::string instance_name_; std::string instance_name_;
skipping to change at line 428 skipping to change at line 426
}); });
} }
microservice_manager<C> &ms_mgr_; microservice_manager<C> &ms_mgr_;
std::list<re_pack_inp<T> > re_packs_; std::list<re_pack_inp<T> > re_packs_;
protected: protected:
rule_engine_plugin_manager<T> &re_plugin_mgr_; rule_engine_plugin_manager<T> &re_plugin_mgr_;
}; };
inline bool is_continuation_code(int _error_code)
{
// Continue to the next rule engine plugin if the current REP
// returns either of the following:
// - SYS_NOT_SUPPORTED : Signals to the REPF that the REP did nothing.
// - RULE_ENGINE_CONTINUE: Signals to the REPF to continue with the next
REP.
const std::initializer_list<int> continuation_codes = {SYS_NOT_SUPPORTED
, RULE_ENGINE_CONTINUE};
return std::any_of(std::begin(continuation_codes),
std::end(continuation_codes),
[_error_code](auto _ec) { return _ec == _error_code;
});
}
template <typename ER, typename EM, typename T, typename ...As> template <typename ER, typename EM, typename T, typename ...As>
inline error control(std::list<re_pack_inp<T> >& _re_packs, ER _er, EM _em, const std::string& _rn, As &&... _ps) { inline error control(std::list<re_pack_inp<T> >& _re_packs, ER _er, EM _em, const std::string& _rn, As &&... _ps) {
// Iterate over the list of REPs. If the rule exists in one of the REPs, // "unsafe_ms_ctx" is a special keyword that must be processed by the mi
// then execute that REP's rule code. croservice
for (auto itr = begin(_re_packs); itr != end(_re_packs); ++itr) { // handler, "_em". If this keyword is seen, the REPs should be skipped.
bool rule_exists = false; if ("unsafe_ms_ctx" != _rn) {
// Holds the error code of the last REP that processed the rule "_rn
".
// If the rule was NOT processed by any REP, then "last_error_code"
will
// be empty and "_rn" MIGHT reference a microservice. It is VERY imp
ortant that
// "last_error_code" be instantiated in the empty state.
boost::optional<int> last_error_code;
// Iterate over the list of REPs. If the rule exists in one of the R
EPs,
// then execute that REP's rule code.
for (auto itr = begin(_re_packs); itr != end(_re_packs); ++itr) {
bool rule_exists = false;
error err = itr->re_->rule_exists(_rn, itr->re_ctx_, rule_exists); error err = itr->re_->rule_exists(_rn, itr->re_ctx_, rule_exists
);
if (!err.ok()) {
return err;
}
if (rule_exists) { if (!err.ok()) {
err = _er(*itr, _rn, std::forward<As>(_ps)...);
// Continue to the next rule engine plugin if the current REP
// returns either of the following:
// - SYS_NOT_SUPPORTED : Signals to the REPF that the REP did
nothing.
// - RULE_ENGINE_CONTINUE: Signals to the REPF to continue with
the next REP.
const std::initializer_list<int> continuation_codes = {SYS_NOT_S
UPPORTED, RULE_ENGINE_CONTINUE};
const auto pred = [ec = err.code()](const auto _ec) { return _ec
== ec; };
if (std::none_of(begin(continuation_codes), end(continuation_cod
es), pred)) {
return err; return err;
} }
if (rule_exists) {
err = _er(*itr, _rn, std::forward<As>(_ps)...);
last_error_code = err.code();
if (!is_continuation_code(*last_error_code)) {
return err;
}
}
}
// If the rule was processed by a REP and the last error code is zer
o or a continuation
// code, then return the last error code. Checking for zero is equiv
alent to a REP returning
// SUCCESS(). This keeps the REPF from trying to execute rules as mi
croservices.
if (last_error_code && (*last_error_code == 0 || is_continuation_cod
e(*last_error_code))) {
return CODE(*last_error_code);
} }
} }
return _em(_rn, std::forward<As>(_ps)...); return _em(_rn, std::forward<As>(_ps)...);
} }
template<typename T, typename C> template<typename T, typename C>
class rule_exists_manager { class rule_exists_manager {
public: public:
rule_exists_manager(rule_engine_manager<T,C>& _re_mgr) : rule_exists_manager(rule_engine_manager<T,C>& _re_mgr) :
 End of changes. 9 change blocks. 
31 lines changed or deleted 61 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)