LCOV - code coverage report
Current view: top level - include/hpactor/net - service_discovery.hpp (source / functions) Coverage Total Hit
Test: HPActor Coverage Lines: 100.0 % 3 3
Test Date: 2026-05-20 02:24:49 Functions: 66.7 % 3 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright 2026 HPActor Contributors
       2                 :             : //
       3                 :             : // Licensed under the Apache License, Version 2.0 (the "License");
       4                 :             : // you may not use this file except in compliance with the License.
       5                 :             : // You may obtain a copy of the License at
       6                 :             : //
       7                 :             : //     http://www.apache.org/licenses/LICENSE-2.0
       8                 :             : //
       9                 :             : // Unless required by applicable law or agreed to in writing, software
      10                 :             : // distributed under the License is distributed on an "AS IS" BASIS,
      11                 :             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12                 :             : // See the License for the specific language governing permissions and
      13                 :             : // limitations under the License.
      14                 :             : 
      15                 :             : #pragma once
      16                 :             : 
      17                 :             : #include <hpactor/adt/node_identity.hpp>
      18                 :             : #include <hpactor/net/acceptor.hpp>
      19                 :             : #include <hpactor/types/types.hpp>
      20                 :             : 
      21                 :             : #include <chrono>
      22                 :             : #include <cstdint>
      23                 :             : #include <functional>
      24                 :             : #include <string>
      25                 :             : #include <unordered_map>
      26                 :             : #include <vector>
      27                 :             : 
      28                 :             : namespace hpactor::net {
      29                 :             : 
      30                 :             : enum class MemberStatus : uint8_t { Alive, Suspicious, Dead, Left };
      31                 :             : 
      32                 :             : struct Member {
      33                 :             :     NodeIdentity identity;
      34                 :             :     std::vector<std::string> actor_types;
      35                 :             :     MemberStatus status = MemberStatus::Alive;
      36                 :             :     uint64_t incarnation = 0;
      37                 :             :     // Not transmitted on wire — receivers set to steady_clock::now() on
      38                 :             :     // receipt.
      39                 :             :     std::chrono::steady_clock::time_point last_seen;
      40                 :             : };
      41                 :             : 
      42                 :             : using MemberChangeCallback = std::function<void(const Member&, bool joined)>;
      43                 :             : 
      44                 :             : class IServiceDiscovery {
      45                 :             :   public:
      46                 :          36 :     virtual ~IServiceDiscovery() = default;
      47                 :             : 
      48                 :             :     virtual void start() = 0;
      49                 :             :     virtual void stop() = 0;
      50                 :             : 
      51                 :             :     virtual std::vector<Member> discover_all() const = 0;
      52                 :             :     virtual const Member* discover(EndPoint) const = 0;
      53                 :             :     virtual void announce(Member local_state) = 0;
      54                 :             :     virtual void on_member_change(MemberChangeCallback) = 0;
      55                 :             :     virtual std::string backend_name() const = 0;
      56                 :             : 
      57                 :           1 :     virtual const std::unordered_map<EndPoint, Member>* raw_members() const {
      58                 :           1 :         return nullptr;
      59                 :             :     }
      60                 :             : };
      61                 :             : 
      62                 :             : } // namespace hpactor::net
        

Generated by: LCOV version 2.0-1