UniSet @VERSION@
HealthChecker.h
1/*
2 * Copyright (c) 2026 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 */
8// -------------------------------------------------------------------------
9#ifndef HealthChecker_H_
10#define HealthChecker_H_
11// -------------------------------------------------------------------------
12#include <memory>
13#include <string>
14#include <atomic>
15#include <Poco/Process.h>
16#include "ProcessInfo.h"
17#include "Configuration.h"
18#include "UInterface.h"
19// -------------------------------------------------------------------------
20namespace uniset
21{
27 {
28 public:
29 explicit HealthChecker(std::shared_ptr<Configuration> conf = nullptr);
30
38 bool waitForReady(const ReadyCheck& check, size_t timeout_msec);
39
47 bool waitForReady(const ReadyCheck& check, size_t timeout_msec,
48 const std::atomic<bool>& cancelFlag);
49
54 bool checkOnce(const ReadyCheck& check);
55
61 static bool isProcessAlive(Poco::Process::PID pid);
62
66 static ReadyCheck parseReadyCheck(const std::string& checkStr);
67
68 private:
69 bool checkTCP(const std::string& hostPort, size_t timeout_msec);
70 bool checkCORBA(const std::string& objectName, size_t timeout_msec, size_t pause_msec);
71 bool checkCORBA(const std::string& objectName, size_t timeout_msec, size_t pause_msec,
72 const std::atomic<bool>& cancelFlag);
73 bool checkHTTP(const std::string& url, size_t timeout_msec);
74 bool checkFile(const std::string& path);
75
76 std::shared_ptr<Configuration> conf_;
77 std::shared_ptr<UInterface> ui_;
78 };
79
80} // end of namespace uniset
81// -------------------------------------------------------------------------
82#endif // HealthChecker_H_
83// -------------------------------------------------------------------------
Definition HealthChecker.h:27
static bool isProcessAlive(Poco::Process::PID pid)
Definition HealthChecker.cc:123
bool checkOnce(const ReadyCheck &check)
Definition HealthChecker.cc:98
static ReadyCheck parseReadyCheck(const std::string &checkStr)
Definition HealthChecker.cc:131
bool waitForReady(const ReadyCheck &check, size_t timeout_msec)
Definition HealthChecker.cc:32
Definition AccessConfig.h:30
Definition ProcessInfo.h:51