Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elasticsearch history api #1682 #1725

Merged
merged 16 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,12 @@ namespace graphene { namespace app {

if(_app.is_plugin_enabled("elasticsearch")) {
auto es = _app.get_plugin<elasticsearch::elasticsearch_plugin>("elasticsearch");
auto _thread = std::make_shared<fc::thread>("elasticsearch");
return _thread->async([&](){ return es->get_account_history(account, stop, limit, start); },
"thread invoke for method " BOOST_PP_STRINGIZE(method_name)).wait();
if(es.get()->get_running_mode() != elasticsearch::mode::only_save) {
auto _thread = std::make_shared<fc::thread>("elasticsearch");
pmconrad marked this conversation as resolved.
Show resolved Hide resolved
return _thread->async([&es, &account, &stop, &limit, &start]() {
return es->get_account_history(account, stop, limit, start);
}, "thread invoke for method " BOOST_PP_STRINGIZE(method_name)).wait();
}
}

const auto& hist_idx = db.get_index_type<account_transaction_history_index>();
Expand Down
6 changes: 6 additions & 0 deletions libraries/plugins/elasticsearch/elasticsearch_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,10 @@ graphene::utilities::ES elasticsearch_plugin::prepareHistoryQuery(string query)
return es;
}

mode elasticsearch_plugin::get_running_mode()
{
return my->_elasticsearch_mode;
}


} }
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace detail
class elasticsearch_plugin_impl;
}

enum mode { only_save = 0 , only_query = 1, all = 2 };

class elasticsearch_plugin : public graphene::app::plugin
{
public:
Expand All @@ -67,6 +69,7 @@ class elasticsearch_plugin : public graphene::app::plugin
operation_history_object get_operation_by_id(operation_history_id_type id);
vector<operation_history_object> get_account_history(const account_id_type account_id,
operation_history_id_type stop, unsigned limit, operation_history_id_type start);
mode get_running_mode();

friend class detail::elasticsearch_plugin_impl;
std::unique_ptr<detail::elasticsearch_plugin_impl> my;
Expand All @@ -76,7 +79,6 @@ class elasticsearch_plugin : public graphene::app::plugin
graphene::utilities::ES prepareHistoryQuery(string query);
};

enum mode { only_save = 0 , only_query = 1, all = 2 };

struct operation_visitor
{
Expand Down
1 change: 1 addition & 0 deletions tests/common/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ database_fixture::database_fixture(const fc::time_point_sec &initial_timestamp)
options.insert(std::make_pair("elasticsearch-visitor", boost::program_options::variable_value(false, false)));
options.insert(std::make_pair("elasticsearch-operation-object", boost::program_options::variable_value(true, false)));
options.insert(std::make_pair("elasticsearch-operation-string", boost::program_options::variable_value(true, false)));
options.insert(std::make_pair("elasticsearch-mode", boost::program_options::variable_value(uint16_t(2), false)));

esplugin->plugin_initialize(options);
esplugin->plugin_startup();
Expand Down