| #ifndef THIRD_PARTY_MILOTIC_INTERNAL_CC_PROXY_CPER_PLUGIN_H_ |
| #define THIRD_PARTY_MILOTIC_INTERNAL_CC_PROXY_CPER_PLUGIN_H_ |
| |
| #include <memory> |
| #include <string> |
| #include <utility> |
| |
| #include "absl/log/log.h" |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "cper/manager.h" |
| #include "proxy.h" |
| #include "proxy_config.pb.h" |
| #include "redfish_plugin.h" |
| #include "request_response.h" |
| #include "sse_plugin/collector_storage_manager.h" |
| #include "sse_plugin/storage_manager.h" |
| #include "voyager/priority_queue.hpp" |
| |
| namespace milotic { |
| |
| class CperEventsPlugin : public milotic::RedfishPlugin { |
| public: |
| explicit CperEventsPlugin( |
| const milotic_grpc_proxy::Plugin::CperEvents& config, |
| std::unique_ptr<milotic::EventStorageManager> storage_manager = |
| std::make_unique<milotic::RemoteCollectorStorageManager>(), |
| bool init_events_manager = true) |
| : events_queue_( |
| static_cast<int>(config.events_manager().events_queue_size())), |
| storage_manager_(storage_manager.get()), |
| events_manager_(config, std::move(storage_manager), &events_queue_), |
| put_processed_events_path_( |
| config.events_manager().put_processed_events_path()), |
| subscribe_events_path_(config.events_manager().subscribe_events_path()), |
| collector_request_id_filter_( |
| config.events_manager().collector_request_id_filter()) { |
| init_events_manager_ = init_events_manager; |
| } |
| |
| ~CperEventsPlugin() override; |
| |
| RequestAction PreprocessRequest(RedfishPlugin::RequestVerb verb, |
| ProxyRequest& request) override; |
| |
| absl::StatusOr<ProxyResponse> HandleRequest( |
| RedfishPlugin::RequestVerb verb, |
| std::unique_ptr<ProxyRequest> request) override; |
| absl::Status Subscribe(std::unique_ptr<ProxyRequest> request, |
| EventHandler* event_handler) override; |
| |
| absl::Status Initialize(milotic::Proxy* proxy) override; |
| |
| CperEventsPlugin(const CperEventsPlugin&) = delete; |
| CperEventsPlugin& operator=(const CperEventsPlugin&) = delete; |
| |
| private: |
| absl::StatusOr<ProxyResponse> HandleGetHealth( |
| std::unique_ptr<ProxyRequest> request); |
| absl::StatusOr<ProxyResponse> HandlePutProcessedEvents( |
| std::unique_ptr<ProxyRequest> request); |
| absl::StatusOr<ProxyResponse> HandleFetchHealthRollup( |
| std::unique_ptr<ProxyRequest> request); |
| |
| voyager::TelemetryPriorityQueue events_queue_; |
| milotic::EventStorageManager* storage_manager_; |
| CperEventsManager events_manager_; |
| bool init_events_manager_; |
| milotic::Proxy* proxy_ = nullptr; |
| std::string put_processed_events_path_; |
| std::string subscribe_events_path_; |
| std::string collector_request_id_filter_; |
| }; |
| |
| } // namespace milotic |
| |
| #endif // THIRD_PARTY_MILOTIC_INTERNAL_CC_PROXY_CPER_PLUGIN_H_ |