blob: d5d33d4d4e16a12215682e61d8377ccdfb8a0300 [file] [log] [blame] [edit]
#ifndef PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_SERVICE_IMPL_H_
#define PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_SERVICE_IMPL_H_
#include <memory>
#include <ostream>
#include <utility>
#include "action_context.h"
#include "safepower_agent.pb.h"
#include "state_updater.h"
#include "absl/base/nullability.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
namespace safepower_agent {
class ServiceImpl {
public:
explicit ServiceImpl(
const
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>&
system_state_updater,
const
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>&
global_system_state_updater,
std::unique_ptr<ActionContextManager> action_context_manager)
: system_state_updater_(system_state_updater),
global_system_state_updater_(global_system_state_updater),
action_context_manager_(std::move(action_context_manager)) {}
absl::Status StartAction(
const safepower_agent_proto::StartActionRequest& request);
absl::StatusOr<
std::shared_ptr<StateUpdater<safepower_agent_proto::ActionStateLog>>>
MonitorAction(const safepower_agent_proto::MonitorActionRequest& request);
absl::StatusOr<
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>>
MonitorState();
void GetSupportedActions(
safepower_agent_proto::GetSupportedActionsResponse& response);
absl::Status SystemStateUpdate(
const safepower_agent_proto::SystemState& request);
// Dumps the internal state of the SafepowerLocalAgentImpl to the provided
// stream.
void DumpSafepowerState(std::ostream& os) const;
private:
absl::Status CheckDisruption() const;
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>
system_state_updater_;
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>
global_system_state_updater_;
std::unique_ptr<ActionContextManager> action_context_manager_;
};
} // namespace safepower_agent
#endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_SERVICE_IMPL_H_