SPARK-1514, Server side SDK code complete.
This commit is contained in:
1 parent
2885d929a8
commit
e29ea5d89b
39 files changed
+936
-234
No files matched your search
@@ -0,0 +1,50 @@
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderBuilder.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include "lib/plugin/SparkServices.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/dll.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace plugin {
|
||||
|
||||
using namespace bts::orderman;
|
||||
|
||||
void init_plugins(SparkServices &services) {
|
||||
|
||||
static std::vector<decltype (boost::dll::import<void (SparkServices&)>(boost::filesystem::path(),""))> keep_alive;
|
||||
|
||||
auto plugin_path = os::sparkd_wd() + "/plugins/";
|
||||
if (!boost::filesystem::is_directory(plugin_path)) {
|
||||
LOG(Plugin, Info,
|
||||
"No plugin directory found at {}. Skipping plugin loading",
|
||||
plugin_path);
|
||||
return;
|
||||
}
|
||||
|
||||
boost::filesystem::directory_iterator end;
|
||||
for (auto iter = boost::filesystem::directory_iterator(plugin_path);
|
||||
iter != end; ++iter) {
|
||||
auto &f = *iter;
|
||||
|
||||
auto pl = f.path().string();
|
||||
LOG(Plugin, Info, "Attempting to initialize plugin {}", pl);
|
||||
try {
|
||||
auto init_plugin = boost::dll::import<void(SparkServices &)>(
|
||||
f.path(), "init_spark_plugin");
|
||||
init_plugin(services);
|
||||
keep_alive.push_back(init_plugin);
|
||||
LOG(Plugin, Info, "Successfully initialized plugin {}", pl);
|
||||
} catch (boost::system::system_error const &e) {
|
||||
LOG(Plugin, Error,
|
||||
"Failed to initialize plugin {}. Error: {} (OS error code: {})",
|
||||
pl, std::string(e.what()), e.code());
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace plugin
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user