Changing Executor interface to allow for more flexible tasks down the road
This commit is contained in:
@@ -12,7 +12,7 @@ namespace daggy {
|
||||
|
||||
const std::string getName() const override { return "ForkingTaskExecutor"; }
|
||||
|
||||
AttemptRecord runCommand(std::vector<std::string> cmd) override;
|
||||
AttemptRecord runCommand(const Task &task) override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace daggy {
|
||||
virtual const std::string getName() const = 0;
|
||||
|
||||
// This will block if the dag_executor is full
|
||||
virtual AttemptRecord runCommand(std::vector<std::string> cmd) = 0;
|
||||
virtual AttemptRecord runCommand(const Task &task) = 0;
|
||||
|
||||
ThreadPool threadPool;
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace daggy {
|
||||
logger.updateTaskState(runID, task.name, RunState::RUNNING);
|
||||
|
||||
while (attempts.size() < task.maxRetries + 1) {
|
||||
attempts.push_back(executor.runCommand(task.command));
|
||||
attempts.push_back(executor.runCommand(task));
|
||||
logger.logTaskAttempt(runID, task.name, attempts.back());
|
||||
if (attempts.back().rc == 0) break;
|
||||
logger.updateTaskState(runID, task.name, RunState::RETRY);
|
||||
@@ -169,8 +169,8 @@ namespace daggy {
|
||||
executor.threadPool.addTasks(tq);
|
||||
}
|
||||
if (running > 0 and errored == running) {
|
||||
logger.updateDAGRunState(runID, RunState::ERRORED);
|
||||
break;
|
||||
logger.updateDAGRunState(runID, RunState::ERRORED);
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(250ms);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ std::string slurp(int fd) {
|
||||
}
|
||||
|
||||
daggy::AttemptRecord
|
||||
ForkingTaskExecutor::runCommand(std::vector<std::string> cmd) {
|
||||
ForkingTaskExecutor::runCommand(const Task &task) {
|
||||
AttemptRecord rec;
|
||||
|
||||
rec.startTime = Clock::now();
|
||||
|
||||
// Need to convert the strings
|
||||
std::vector<char *> argv;
|
||||
for (const auto &s : cmd) {
|
||||
for (const auto &s : task.command) {
|
||||
argv.push_back(const_cast<char *>(s.c_str()));
|
||||
}
|
||||
argv.push_back(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user