Пример #1
0
void elliptics_service_t::on_bulk_read_completed(deferred<std::map<std::string, std::string> > promise,
	const key_name_map &keys,
	const ioremap::elliptics::sync_read_result &result,
	const ioremap::elliptics::error_info &error)
{
	if (error) {
		promise.abort(-error.code(), error.message());
	} else {
		std::map<std::string, std::string> read_result;

		for (size_t i = 0; i < result.size(); ++i) {
			const auto &entry = result[i];
			const auto &id = reinterpret_cast<const dnet_raw_id &>(entry.command()->id);

			auto it = keys.find(id);

			if (it == keys.end()) {
				continue;
			}

			read_result[it->second] = entry.file().to_string();
		}

		promise.write(read_result);
	}
}
Пример #2
0
void elliptics_service_t::on_remove_completed(deferred<void> promise,
	const ioremap::elliptics::sync_remove_result &,
	const ioremap::elliptics::error_info &error)
{
	if (error) {
		promise.abort(-error.code(), error.message());
	} else {
		promise.close();
	}
}
Пример #3
0
void elliptics_service_t::on_find_completed(deferred<std::vector<std::string> > promise,
	const ioremap::elliptics::sync_find_indexes_result &result,
	const ioremap::elliptics::error_info &error)
{
	if (error) {
		promise.abort(-error.code(), error.message());
	} else {
		promise.write(storage::elliptics_storage_t::convert_list_result(result));
	}
}
Пример #4
0
void elliptics_service_t::on_read_completed(deferred<std::string> promise,
	const ioremap::elliptics::sync_read_result &result,
	const ioremap::elliptics::error_info &error)
{
	if (error) {
		promise.abort(-error.code(), error.message());
	} else {
		promise.write(result[0].file().to_string());
	}
}
Пример #5
0
void
control_service_t::on_config_void_result(deferred<command_result<void>> promise,
                                         const std::error_code& ec)
{
    if(ec) {
        promise.write(
            command_result<void>(static_cast<raft_errc>(ec.value()), m_config_actor->leader_id())
        );
    } else {
        promise.write(command_result<void>());
    }
}
Пример #6
0
void
control_service_t::on_config_change_result(
    deferred<command_result<cluster_change_result>> promise,
    const boost::variant<std::error_code, cluster_change_result>& result
) {
    if(boost::get<std::error_code>(&result)) {
        auto errc = static_cast<raft_errc>(boost::get<std::error_code>(result).value());
        promise.write(
            command_result<cluster_change_result>(errc, m_config_actor->leader_id())
        );
    } else {
        auto result_code = boost::get<cluster_change_result>(result);
        promise.write(command_result<cluster_change_result>(result_code));
    }
}
Пример #7
0
void
control_service_t::on_config_change_error(const std::string& machine,
                                          uint64_t operation_id,
                                          deferred<command_result<cluster_change_result>> promise,
                                          const std::error_code& ec)
{
    if(ec) {
        m_config_actor->machine().pop_operation(machine, operation_id);

        auto errc = static_cast<raft_errc>(ec.value());
        promise.write(
            command_result<cluster_change_result>(errc, m_config_actor->leader_id())
        );
    }
}