92 lines
2.5 KiB
C++
92 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include <curl/curl.h>
|
|
#include <rapidjson/document.h>
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
#include "DAG.hpp"
|
|
#include "Defines.hpp"
|
|
#include "daggy/executors/task/TaskExecutor.hpp"
|
|
#include "daggy/loggers/dag_run/DAGRunLogger.hpp"
|
|
|
|
namespace rj = rapidjson;
|
|
|
|
namespace daggy {
|
|
using TaskDAG = DAG<std::string, Task>;
|
|
|
|
std::string globalSub(std::string string, const std::string &pattern,
|
|
const std::string &replacement);
|
|
|
|
std::unordered_set<std::string> matchingParameters(
|
|
const std::vector<std::string> &input, const ConfigValues &values);
|
|
|
|
std::vector<std::unordered_map<std::string, std::string>>
|
|
generateCartesianValues(const ConfigValues &values);
|
|
|
|
std::vector<Command> interpolateValues(const std::vector<std::string> &raw,
|
|
const ConfigValues &values);
|
|
|
|
TaskSet expandTaskSet(const TaskSet &tasks,
|
|
executors::task::TaskExecutor &executor,
|
|
const ConfigValues &interpolatedValues = {});
|
|
|
|
TaskDAG buildDAGFromTasks(
|
|
const TaskSet &tasks,
|
|
const std::unordered_map<std::string,
|
|
std::vector<loggers::dag_run::StateUpdateRecord>>
|
|
&updates = {});
|
|
|
|
void updateDAGFromTasks(TaskDAG &dag, const TaskSet &tasks);
|
|
|
|
std::ostream &operator<<(std::ostream &os, const TimePoint &tp);
|
|
|
|
// HTTP helpers
|
|
enum HTTPCode : long
|
|
{
|
|
Ok = 200,
|
|
Not_Found = 404,
|
|
Not_Acceptable = 406,
|
|
Server_Error = 500
|
|
};
|
|
|
|
struct HTTPResponse
|
|
{
|
|
HTTPCode code;
|
|
std::string body;
|
|
};
|
|
|
|
HTTPResponse HTTP_REQUEST(const std::string &url,
|
|
const std::string &payload = "",
|
|
const std::string &method = "GET",
|
|
bool trace = false);
|
|
|
|
std::pair<HTTPCode, rj::Document> JSON_HTTP_REQUEST(
|
|
const std::string &url, const std::string &payload = "",
|
|
const std::string &method = "GET", bool trace = false);
|
|
} // namespace daggy
|
|
|
|
template <typename T>
|
|
void hash_combine(std::size_t &seed, T const &key)
|
|
{
|
|
std::hash<T> hasher;
|
|
seed ^= hasher(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
|
}
|
|
|
|
namespace std {
|
|
template <typename T1, typename T2>
|
|
struct hash<std::pair<T1, T2>>
|
|
{
|
|
std::size_t operator()(std::pair<T1, T2> const &p) const
|
|
{
|
|
std::size_t seed(0);
|
|
::hash_combine(seed, p.first);
|
|
::hash_combine(seed, p.second);
|
|
return seed;
|
|
}
|
|
};
|
|
} // namespace std
|