LCOV - code coverage report
Current view: top level - media/server/main/include - HeartbeatProcedure.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2025-02-18 13:13:53 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 2023 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_HEARTBEAT_PROCEDURE_H_
      21              : #define FIREBOLT_RIALTO_SERVER_HEARTBEAT_PROCEDURE_H_
      22              : 
      23              : #include "IHeartbeatProcedure.h"
      24              : #include <atomic>
      25              : #include <memory>
      26              : 
      27              : namespace firebolt::rialto::server
      28              : {
      29              : class HeartbeatProcedureFactory : public IHeartbeatProcedureFactory
      30              : {
      31              : public:
      32            6 :     HeartbeatProcedureFactory() = default;
      33           12 :     ~HeartbeatProcedureFactory() override = default;
      34              :     std::shared_ptr<IHeartbeatProcedure> createHeartbeatProcedure(const std::shared_ptr<IAckSender> &ackSender,
      35              :                                                                   std::int32_t pingId) const override;
      36              : };
      37              : 
      38              : class HeartbeatProcedure : public std::enable_shared_from_this<HeartbeatProcedure>, public IHeartbeatProcedure
      39              : {
      40              :     class HeartbeatHandler : public IHeartbeatHandler
      41              :     {
      42              :     public:
      43              :         HeartbeatHandler(const std::shared_ptr<HeartbeatProcedure> &procedure, std::int32_t pingId);
      44              :         ~HeartbeatHandler() override;
      45              : 
      46              :         void error() override;
      47              :         std::int32_t id() const override;
      48              : 
      49              :     private:
      50              :         std::shared_ptr<HeartbeatProcedure> m_procedure;
      51              :         const std::int32_t m_kPingId;
      52              :         bool m_success;
      53              :     };
      54              : 
      55              : public:
      56              :     HeartbeatProcedure(const std::shared_ptr<IAckSender> &ackSender, std::int32_t pingId);
      57              :     ~HeartbeatProcedure() override;
      58              :     std::unique_ptr<IHeartbeatHandler> createHandler() override;
      59              : 
      60              : private:
      61              :     void onFinish(bool success);
      62              : 
      63              : private:
      64              :     std::shared_ptr<IAckSender> m_ackSender;
      65              :     const std::int32_t m_kPingId;
      66              :     std::atomic_bool m_success;
      67              : };
      68              : } // namespace firebolt::rialto::server
      69              : 
      70              : #endif // FIREBOLT_RIALTO_SERVER_HEARTBEAT_PROCEDURE_H_
        

Generated by: LCOV version 2.0-1