- Refactoring Defines
- Moving de/serialization routines to a separate header
This commit is contained in:
@@ -3,12 +3,12 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace daggy {
|
#include "Defines.hpp"
|
||||||
using Clock = std::chrono::system_clock;
|
|
||||||
|
|
||||||
|
namespace daggy {
|
||||||
struct AttemptRecord {
|
struct AttemptRecord {
|
||||||
std::chrono::time_point<Clock> startTime;
|
TimePoint startTime;
|
||||||
std::chrono::time_point<Clock> stopTime;
|
TimePoint stopTime;
|
||||||
int rc; // RC from the task
|
int rc; // RC from the task
|
||||||
std::string metaLog; // Logs from the executor
|
std::string metaLog; // Logs from the executor
|
||||||
std::string output; // stdout from command
|
std::string output; // stdout from command
|
||||||
|
|||||||
21
daggy/include/daggy/Defines.hpp
Normal file
21
daggy/include/daggy/Defines.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
namespace daggy {
|
||||||
|
// Commands and parameters
|
||||||
|
using ParameterValue = std::variant<std::string, std::vector<std::string>>;
|
||||||
|
using ParameterValues = std::unordered_map<std::string, ParameterValue>;
|
||||||
|
using Command = std::vector<std::string>;
|
||||||
|
|
||||||
|
// Time
|
||||||
|
using Clock = std::chrono::system_clock;
|
||||||
|
using TimePoint = std::chrono::time_point<Clock>;
|
||||||
|
|
||||||
|
// DAG Runs
|
||||||
|
using DAGDefID = int16_t;
|
||||||
|
using DAGRunID = size_t;
|
||||||
|
}
|
||||||
22
daggy/include/daggy/Serialization.h
Normal file
22
daggy/include/daggy/Serialization.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include <rapidjson/document.h>
|
||||||
|
|
||||||
|
#include "Logger.hpp"
|
||||||
|
#include "TaskExecutor.hpp"
|
||||||
|
#include "Task.hpp"
|
||||||
|
|
||||||
|
namespace rj = rapidjson;
|
||||||
|
|
||||||
|
namespace daggy {
|
||||||
|
ParameterValues parseParameters(const std::string & jsonSpec);
|
||||||
|
ParameterValues parseParameters(const rj::Document & spec);
|
||||||
|
std::vector<Task> buildTasks(const std::string & jsonSpec, const ParameterValues & parameters = {});
|
||||||
|
std::vector<Task> buildTasks(const rj::Document & spec, const ParameterValues & parameters = {});
|
||||||
|
std::vector<Command> expandCommands(const std::vector<std::string> & command, const ParameterValues & parameters);
|
||||||
|
}
|
||||||
@@ -10,22 +10,9 @@
|
|||||||
#include "Logger.hpp"
|
#include "Logger.hpp"
|
||||||
#include "TaskExecutor.hpp"
|
#include "TaskExecutor.hpp"
|
||||||
#include "Task.hpp"
|
#include "Task.hpp"
|
||||||
#include "ThreadPool.hpp"
|
#include "Defines.hpp"
|
||||||
|
|
||||||
namespace rj = rapidjson;
|
|
||||||
|
|
||||||
namespace daggy {
|
namespace daggy {
|
||||||
using ParameterValue = std::variant<std::string, std::vector<std::string>>;
|
|
||||||
using ParameterValues = std::unordered_map<std::string, ParameterValue>;
|
|
||||||
using Command = std::vector<std::string>;
|
|
||||||
|
|
||||||
// Dealing with JSON
|
|
||||||
ParameterValues parseParameters(const std::string & jsonSpec);
|
|
||||||
ParameterValues parseParameters(const rj::Document & spec);
|
|
||||||
std::vector<Task> buildTasks(const std::string & jsonSpec, const ParameterValues & parameters = {});
|
|
||||||
std::vector<Task> buildTasks(const rj::Document & spec, const ParameterValues & parameters = {});
|
|
||||||
std::vector<Command> expandCommands(const std::vector<std::string> & command, const ParameterValues & parameters);
|
|
||||||
|
|
||||||
// DAG execution
|
// DAG execution
|
||||||
// DAG vertex IDs should correspond to the position of tasks in vector. e.g. Vertex ID 0 corresponds to tasks[0]
|
// DAG vertex IDs should correspond to the position of tasks in vector. e.g. Vertex ID 0 corresponds to tasks[0]
|
||||||
// I'm not crazy about this loose coupling, but
|
// I'm not crazy about this loose coupling, but
|
||||||
|
|||||||
Reference in New Issue
Block a user