38 行
793 B
C++
38 行
793 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <mutex>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace csp::services {
|
|
|
|
class KbImportRunner {
|
|
public:
|
|
static KbImportRunner& Instance();
|
|
|
|
void Configure(std::string db_path);
|
|
bool TriggerAsync(const std::string& trigger);
|
|
|
|
bool IsRunning() const;
|
|
std::string LastCommand() const;
|
|
std::optional<int> LastExitCode() const;
|
|
int64_t LastStartedAt() const;
|
|
int64_t LastFinishedAt() const;
|
|
std::string LastTrigger() const;
|
|
|
|
private:
|
|
KbImportRunner() = default;
|
|
|
|
mutable std::mutex mu_;
|
|
std::string db_path_;
|
|
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;
|
|
std::string last_trigger_;
|
|
};
|
|
|
|
} // namespace csp::services
|