41 行
850 B
C++
41 行
850 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <mutex>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace csp::services {
|
|
|
|
struct ImportRunOptions {
|
|
bool clear_all_problems = false;
|
|
};
|
|
|
|
class ImportRunner {
|
|
public:
|
|
static ImportRunner& Instance();
|
|
|
|
void Configure(std::string db_path);
|
|
bool TriggerAsync(const std::string& trigger, const ImportRunOptions& options);
|
|
void AutoStartIfEnabled();
|
|
|
|
bool IsRunning() const;
|
|
std::string LastCommand() const;
|
|
std::optional<int> LastExitCode() const;
|
|
int64_t LastStartedAt() const;
|
|
int64_t LastFinishedAt() const;
|
|
|
|
private:
|
|
ImportRunner() = default;
|
|
|
|
std::string db_path_;
|
|
mutable std::mutex mu_;
|
|
bool running_ = false;
|
|
std::string last_command_;
|
|
std::optional<int> last_exit_code_;
|
|
int64_t last_started_at_ = 0;
|
|
int64_t last_finished_at_ = 0;
|
|
};
|
|
|
|
} // namespace csp::services
|