LCOV - code coverage report
Current view: top level - media/server/ipc/include - PrivateMetricsModuleService.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-09-11 17:36:12 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2026 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #ifndef FIREBOLT_RIALTO_SERVER_IPC_PRIVATE_METRICS_MODULE_SERVICE_H_
      21              : #define FIREBOLT_RIALTO_SERVER_IPC_PRIVATE_METRICS_MODULE_SERVICE_H_
      22              : 
      23              : #include "IMetricsCollectorClient.h"
      24              : #include "IPrivateMetricsModuleService.h"
      25              : #include "IPrivateMetricsService.h"
      26              : #include <atomic>
      27              : #include <cstdint>
      28              : #include <map>
      29              : #include <memory>
      30              : #include <mutex>
      31              : 
      32              : namespace firebolt::rialto::server::ipc
      33              : {
      34              : class PrivateMetricsModuleServiceFactory : public IPrivateMetricsModuleServiceFactory
      35              : {
      36              : public:
      37            1 :     PrivateMetricsModuleServiceFactory() = default;
      38            2 :     ~PrivateMetricsModuleServiceFactory() override = default;
      39              : 
      40              :     std::shared_ptr<IPrivateMetricsModuleService> create(service::IPrivateMetricsService &metricsService) const override;
      41              : };
      42              : 
      43              : class PrivateMetricsModuleService : public IPrivateMetricsModuleService,
      44              :                                     public firebolt::rialto::server::IMetricsCollectorClient
      45              : {
      46              : public:
      47              :     explicit PrivateMetricsModuleService(service::IPrivateMetricsService &metricsService);
      48              :     ~PrivateMetricsModuleService() override;
      49              : 
      50              :     // IPrivateMetricsModuleService
      51              :     void clientConnected(const std::shared_ptr<::firebolt::rialto::ipc::IClient> &ipcClient) override;
      52              :     void clientDisconnected(const std::shared_ptr<::firebolt::rialto::ipc::IClient> &ipcClient) override;
      53              : 
      54              :     void notifyApplicationStateChanged(ApplicationState newState) override;
      55              : 
      56              :     // PrivateMetricsModule RPC handlers
      57              :     void reportClientMetrics(::google::protobuf::RpcController *controller,
      58              :                              const ::firebolt::rialto::ReportClientMetricsRequest *request,
      59              :                              ::firebolt::rialto::ReportClientMetricsResponse *response,
      60              :                              ::google::protobuf::Closure *done) override;
      61              :     void notifyClientReady(::google::protobuf::RpcController *controller,
      62              :                            const ::firebolt::rialto::NotifyClientReadyRequest *request,
      63              :                            ::firebolt::rialto::NotifyClientReadyResponse *response,
      64              :                            ::google::protobuf::Closure *done) override;
      65              : 
      66              :     // IMetricsCollectorClient
      67              :     void requestMetricsSample(int clientId, std::uint64_t sampleId,
      68              :                               firebolt::rialto::server::MetricsSampleReason reason) override;
      69              : 
      70              : private:
      71              :     service::IPrivateMetricsService &m_metricsService;
      72              :     std::atomic<int> m_nextClientId{1};
      73              :     std::mutex m_mutex;
      74              : 
      75              :     // Map IPC client pointer → client ID
      76              :     std::map<std::shared_ptr<::firebolt::rialto::ipc::IClient>, int> m_clientIds;
      77              :     // Map client ID → IPC client pointer (for sending events back)
      78              :     std::map<int, std::shared_ptr<::firebolt::rialto::ipc::IClient>> m_ipcClients;
      79              : };
      80              : } // namespace firebolt::rialto::server::ipc
      81              : 
      82              : #endif // FIREBOLT_RIALTO_SERVER_IPC_PRIVATE_METRICS_MODULE_SERVICE_H_
        

Generated by: LCOV version 2.0-1