tasks: rename parent_data to task_info and move it
parent_data struct contains info that is common for each task, not only in parent-child relationship context. To use it this way without confusion, its name is changed to task_info. In order to be able to widely and comfortably use task_info, it is moved from tasks/task_manager.hh to tasks/types.hh and slightly extended.
This commit is contained in:
@@ -52,7 +52,7 @@ void set_task_manager_test(http_context& ctx, routes& r, db::config& cfg) {
|
||||
it = req->query_parameters.find("entity");
|
||||
std::string entity = it != req->query_parameters.end() ? it->second : "";
|
||||
it = req->query_parameters.find("parent_id");
|
||||
tasks::task_manager::parent_data data;
|
||||
tasks::task_info data;
|
||||
if (it != req->query_parameters.end()) {
|
||||
data.id = tasks::task_id{utils::UUID{it->second}};
|
||||
auto parent_ptr = co_await tasks::task_manager::lookup_task_on_all_shards(ctx.tm, data.id);
|
||||
|
||||
@@ -65,17 +65,6 @@ public:
|
||||
failed
|
||||
};
|
||||
|
||||
struct parent_data {
|
||||
task_id id;
|
||||
unsigned shard;
|
||||
|
||||
parent_data() : id(task_id::create_null_id()) {}
|
||||
|
||||
operator bool() const noexcept {
|
||||
return bool(id);
|
||||
}
|
||||
};
|
||||
|
||||
class task : public enable_lw_shared_from_this<task> {
|
||||
public:
|
||||
struct progress {
|
||||
@@ -332,7 +321,7 @@ public:
|
||||
|
||||
template<typename T>
|
||||
requires std::is_base_of_v<task_manager::task::impl, T>
|
||||
future<task_id> make_task(unsigned shard, task_id id = task_id::create_null_id(), std::string keyspace = "", std::string table = "", std::string type = "", std::string entity = "", parent_data parent_d = parent_data{}) {
|
||||
future<task_id> make_task(unsigned shard, task_id id = task_id::create_null_id(), std::string keyspace = "", std::string table = "", std::string type = "", std::string entity = "", task_info parent_d = task_info{}) {
|
||||
foreign_task_ptr parent;
|
||||
uint64_t sequence_number = 0;
|
||||
if (parent_d) {
|
||||
|
||||
@@ -14,4 +14,16 @@ namespace tasks {
|
||||
|
||||
using task_id = utils::tagged_uuid<struct task_id_tag>;
|
||||
|
||||
struct task_info {
|
||||
task_id id;
|
||||
unsigned shard;
|
||||
|
||||
task_info() noexcept : id(task_id::create_null_id()) {}
|
||||
task_info(task_id id, unsigned parent_shard) noexcept : id(id), shard(parent_shard) {}
|
||||
|
||||
operator bool() const noexcept {
|
||||
return bool(id);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user