本文整理汇总了C++中PluginResponse::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginResponse::push_back方法的具体用法?C++ PluginResponse::push_back怎么用?C++ PluginResponse::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginResponse
的用法示例。
在下文中一共展示了PluginResponse::push_back方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call
Status ConfigPlugin::call(const PluginRequest& request,
PluginResponse& response) {
if (request.count("action") == 0) {
return Status(1, "Config plugins require an action in PluginRequest");
}
if (request.at("action") == "genConfig") {
std::map<std::string, std::string> config;
auto stat = genConfig(config);
response.push_back(config);
return stat;
} else if (request.at("action") == "genPack") {
if (request.count("name") == 0 || request.count("value") == 0) {
return Status(1, "Missing name or value");
}
std::string pack;
auto stat = genPack(request.at("name"), request.at("value"), pack);
response.push_back({{request.at("name"), pack}});
return stat;
} else if (request.at("action") == "update") {
if (request.count("source") == 0 || request.count("data") == 0) {
return Status(1, "Missing source or data");
}
return Config::getInstance().update(
{{request.at("source"), request.at("data")}});
}
return Status(1, "Config plugin action unknown: " + request.at("action"));
}
示例2: call
Status TablePlugin::call(const PluginRequest& request,
PluginResponse& response) {
response.clear();
// TablePlugin API calling requires an action.
if (request.count("action") == 0) {
return Status(1, "Table plugins must include a request action");
}
if (request.at("action") == "generate") {
// "generate" runs the table implementation using a PluginRequest with
// optional serialized QueryContext and returns the QueryData results as
// the PluginRequest data.
QueryContext context;
if (request.count("context") > 0) {
setContextFromRequest(request, context);
}
response = generate(context);
} else if (request.at("action") == "columns") {
// "columns" returns a PluginRequest filled with column information
// such as name and type.
const auto& column_list = columns();
for (const auto& column : column_list) {
response.push_back(
{{"name", column.first}, {"type", columnTypeName(column.second)}});
}
} else if (request.at("action") == "definition") {
response.push_back({{"definition", columnDefinition()}});
} else {
return Status(1, "Unknown table plugin action: " + request.at("action"));
}
return Status(0, "OK");
}
示例3: call
Status DatabasePlugin::call(const PluginRequest& request,
PluginResponse& response) {
if (request.count("action") == 0) {
return Status(1, "Database plugin must include a request action");
}
// Get a domain/key, which are used for most database plugin actions.
auto domain = (request.count("domain") > 0) ? request.at("domain") : "";
auto key = (request.count("key") > 0) ? request.at("key") : "";
// Switch over the possible database plugin actions.
if (request.at("action") == "get") {
std::string value;
auto status = this->get(domain, key, value);
response.push_back({{"v", value}});
return status;
} else if (request.at("action") == "put") {
if (request.count("value") == 0) {
return Status(1, "Database plugin put action requires a value");
}
return this->put(domain, key, request.at("value"));
} else if (request.at("action") == "remove") {
return this->remove(domain, key);
} else if (request.at("action") == "scan") {
std::vector<std::string> keys;
auto status = this->scan(domain, keys);
for (const auto& key : keys) {
response.push_back({{"k", key}});
}
return status;
}
return Status(1, "Unknown database plugin action");
}
示例4: callExtension
Status callExtension(const std::string& extension_path,
const std::string& registry,
const std::string& item,
const PluginRequest& request,
PluginResponse& response) {
// Make sure the extension manager path exists, and is writable.
auto status = extensionPathActive(extension_path);
if (!status.ok()) {
return status;
}
ExtensionResponse ext_response;
try {
auto client = EXClient(extension_path);
client.get()->call(ext_response, registry, item, request);
} catch (const std::exception& e) {
return Status(1, "Extension call failed: " + std::string(e.what()));
}
// Convert from Thrift-internal list type to PluginResponse type.
if (ext_response.status.code == ExtensionCode::EXT_SUCCESS) {
for (const auto& item : ext_response.response) {
response.push_back(item);
}
}
return Status(ext_response.status.code, ext_response.status.message);
}
示例5: setResponse
void Plugin::setResponse(const std::string& key,
const boost::property_tree::ptree& tree,
PluginResponse& response) {
std::ostringstream output;
boost::property_tree::write_json(output, tree, false);
response.push_back({{key, output.str()}});
}
示例6: call
Status SpecialWidget::call(const PluginRequest& request,
PluginResponse& response) {
response.push_back(request);
response[0]["from"] = name_;
response[0]["secret_power"] = secretPower(request);
return Status(0, "OK");
}
示例7: routeInfo
PluginResponse TablePlugin::routeInfo() const {
// Route info consists of only the serialized column information.
PluginResponse response;
for (const auto& column : columns()) {
response.push_back({{"name", column.first}, {"type", column.second}});
}
return response;
}
示例8: setResponse
void Plugin::setResponse(const std::string& key,
const boost::property_tree::ptree& tree,
PluginResponse& response) {
std::ostringstream output;
try {
boost::property_tree::write_json(output, tree, false);
} catch (const pt::json_parser::json_parser_error& e) {
// The plugin response could not be serialized.
}
response.push_back({{key, output.str()}});
}
示例9: call
Status DatabasePlugin::call(const PluginRequest& request,
PluginResponse& response) {
if (request.count("action") == 0) {
return Status(1, "Database plugin must include a request action");
}
// Get a domain/key, which are used for most database plugin actions.
auto domain = (request.count("domain") > 0) ? request.at("domain") : "";
auto key = (request.count("key") > 0) ? request.at("key") : "";
// Switch over the possible database plugin actions.
if (request.at("action") == "get") {
std::string value;
auto status = this->get(domain, key, value);
response.push_back({{"v", value}});
return status;
} else if (request.at("action") == "put") {
if (request.count("value") == 0) {
return Status(1, "Database plugin put action requires a value");
}
return this->put(domain, key, request.at("value"));
} else if (request.at("action") == "remove") {
return this->remove(domain, key);
} else if (request.at("action") == "scan") {
// Accumulate scanned keys into a vector.
std::vector<std::string> keys;
// Optionally allow the caller to request a max number of keys.
size_t max = 0;
if (request.count("max") > 0) {
max = std::stoul(request.at("max"));
}
auto status = this->scan(domain, keys, max);
for (const auto& key : keys) {
response.push_back({{"k", key}});
}
return status;
}
return Status(1, "Unknown database plugin action");
}
示例10: call
Status EnrollPlugin::call(const PluginRequest& request,
PluginResponse& response) {
if (FLAGS_disable_enrollment) {
return Status(0, "Enrollment disabled");
}
// Only support the 'enroll' action.
if (request.count("action") == 0 || request.at("action") != "enroll") {
return Status(1, "Enroll plugins require an action");
}
// The 'enroll' API should return a string and implement caching.
auto node_key = this->enroll();
response.push_back({{"node_key", node_key}});
if (node_key.size() == 0) {
return Status(1, "No enrollment key found/retrieved");
} else {
return Status(0, "OK");
}
}
示例11: call
Status call(const PluginRequest& request, PluginResponse& response) {
for (const auto& request_item : request) {
response.push_back({{request_item.first, request_item.second}});
}
return Status(0, "Test success");
}
示例12: routeInfo
/// The route information will usually be provided by the plugin type.
/// The plugin/registry item will set some structures for the plugin
/// to parse and format. BUT a plugin/registry item can also fill this
/// information in if the plugin type/registry type exposes routeInfo as
/// a virtual method.
PluginResponse routeInfo() const {
PluginResponse info;
info.push_back({{"name", name_}});
return info;
}
示例13: call
Status DatabasePlugin::call(const PluginRequest& request,
PluginResponse& response) {
if (request.count("action") == 0) {
return Status(1, "Database plugin must include a request action");
}
// Get a domain/key, which are used for most database plugin actions.
auto domain = (request.count("domain") > 0) ? request.at("domain") : "";
auto key = (request.count("key") > 0) ? request.at("key") : "";
if (request.at("action") == "reset") {
WriteLock lock(kDatabaseReset);
DatabasePlugin::kDBInitialized = false;
// Prevent RocksDB reentrancy by logger plugins during plugin setup.
VLOG(1) << "Resetting the database plugin: " << getName();
auto status = this->reset();
if (!status.ok()) {
// The active database could not be reset, fallback to an ephemeral.
Registry::get().setActive("database", "ephemeral");
LOG(WARNING) << "Unable to reset database plugin: " << getName();
}
DatabasePlugin::kDBInitialized = true;
return status;
}
// Switch over the possible database plugin actions.
ReadLock lock(kDatabaseReset);
if (request.at("action") == "get") {
std::string value;
auto status = this->get(domain, key, value);
response.push_back({{"v", value}});
return status;
} else if (request.at("action") == "put") {
if (request.count("value") == 0) {
return Status(1, "Database plugin put action requires a value");
}
return this->put(domain, key, request.at("value"));
} else if (request.at("action") == "remove") {
return this->remove(domain, key);
} else if (request.at("action") == "remove_range") {
auto key_high = (request.count("high") > 0) ? request.at("key_high") : "";
if (!key_high.empty() && !key.empty()) {
return this->removeRange(domain, key, key_high);
}
return Status(1, "Missing range");
} else if (request.at("action") == "scan") {
// Accumulate scanned keys into a vector.
std::vector<std::string> keys;
// Optionally allow the caller to request a max number of keys.
size_t max = 0;
if (request.count("max") > 0) {
max = std::stoul(request.at("max"));
}
auto status = this->scan(domain, keys, request.at("prefix"), max);
for (const auto& k : keys) {
response.push_back({{"k", k}});
}
return status;
}
return Status(1, "Unknown database plugin action");
}