/src/gpowerd/daemon_context.h
Line | Count | Source |
1 | | #ifndef PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_DAEMON_CONTEXT_H_ |
2 | | #define PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_DAEMON_CONTEXT_H_ |
3 | | |
4 | | #include <cstdint> |
5 | | #include <utility> |
6 | | |
7 | | #include "one/offline_node_entities.pb.h" |
8 | | #include "disruption_manager.h" |
9 | | #include "persistent_storage.h" |
10 | | #include "safepower_agent_config.pb.h" |
11 | | #include "system_state.pb.h" |
12 | | #include "scheduler_interface.h" |
13 | | #include "absl/base/nullability.h" |
14 | | #include "absl/status/statusor.h" |
15 | | #include "absl/time/clock.h" |
16 | | #include "absl/time/time.h" |
17 | | |
18 | | namespace safepower_agent { |
19 | | |
20 | | class SafepowerLocalAgentImpl; |
21 | | |
22 | | class DaemonContext { |
23 | | public: |
24 | | DaemonContext(); |
25 | | virtual ~DaemonContext(); |
26 | | |
27 | | static DaemonContext& Get(); |
28 | | |
29 | 0 | virtual absl::Time now() const { return absl::Now(); } |
30 | | |
31 | | virtual uint64_t epoch_ms() = 0; |
32 | | virtual SchedulerInterface& scheduler() = 0; |
33 | | virtual PersistentStorageManager& persistent_storage_manager() = 0; |
34 | | |
35 | | virtual absl::StatusOr<safepower_agent_proto::BuildInfo> GetBuildInfo() |
36 | | const = 0; |
37 | | |
38 | 0 | const safepower_agent_config::SafePowerAgentConfig& config() const { |
39 | 0 | return config_; |
40 | 0 | } |
41 | | |
42 | 0 | void set_config(safepower_agent_config::SafePowerAgentConfig config) { |
43 | 0 | config_ = std::move(config); |
44 | 0 | } |
45 | | |
46 | 0 | DisruptionManager& disruption_manager() { return disruption_manager_; } |
47 | | |
48 | | void set_offline_node_entities( |
49 | | production_msv::node_entities_proto::OfflineNodeEntityInformation |
50 | 0 | offline_node_entities) { |
51 | 0 | offline_node_entities_ = std::move(offline_node_entities); |
52 | 0 | } |
53 | | |
54 | | const production_msv::node_entities_proto::OfflineNodeEntityInformation& |
55 | 0 | offline_node_entities() const { |
56 | 0 | return offline_node_entities_; |
57 | 0 | } |
58 | | |
59 | 0 | void set_safe_power_service(SafepowerLocalAgentImpl* safe_power_service) { |
60 | 0 | safepower_service_ = safe_power_service; |
61 | 0 | } |
62 | 0 | SafepowerLocalAgentImpl* safe_power_service() const { |
63 | 0 | return safepower_service_; |
64 | 0 | } |
65 | | |
66 | | private: |
67 | | static DaemonContext* instance_; |
68 | | safepower_agent_config::SafePowerAgentConfig config_; |
69 | | ::production_msv::node_entities_proto::OfflineNodeEntityInformation |
70 | | offline_node_entities_; |
71 | | |
72 | | DisruptionManager disruption_manager_; |
73 | | SafepowerLocalAgentImpl* safepower_service_ = nullptr; |
74 | | }; |
75 | | } // namespace safepower_agent |
76 | | |
77 | | #endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_DAEMON_CONTEXT_H_ |