11#include "edge_metrics_provider.hpp"
13namespace presage::smartspectra::grpc_bindings {
15template<container::settings::IntegrationMode TIntegrationMode>
16EdgeMetricsProvider<TIntegrationMode>::EdgeMetricsProvider(std::shared_ptr<BackgroundContainer> container) {
17 SwapContainer(container);
20template<container::settings::IntegrationMode TIntegrationMode>
21void EdgeMetricsProvider<TIntegrationMode>::SwapContainer(std::shared_ptr<BackgroundContainer> new_container) {
22 this->container.reset();
23 this->container = std::move(new_container);
24 if (this->container ==
nullptr) {
25 this->Finish(grpc::Status(
26 grpc::StatusCode::FAILED_PRECONDITION,
27 "Physiology Preprocessing is not running, unable to get metrics."
30 auto status = this->container->SetOnEdgeMetricsOutput(
31 [
this](
const presage::physiology::Metrics& metrics_output, int64_t timestamp) {
32 this->EnqueueWrite(metrics_output);
33 return absl::OkStatus();
37 this->Finish(rpc::abslStatusToGrpc(status));