Coverage Report

Created: 2026-10-16 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pdns/pdns/dnsdistdist/remote_logger_pool.hh
Line
Count
Source
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22
#pragma once
23
#include "config.h"
24
#include "remote_logger.hh"
25
#include <atomic>
26
#include <cstddef>
27
#include <memory>
28
#include <vector>
29
30
class RemoteLoggerPool : public RemoteLoggerInterface
31
{
32
public:
33
  // this expects a non-empty vector
34
  RemoteLoggerPool(std::vector<std::shared_ptr<RemoteLoggerInterface>>&& pool);
35
  RemoteLoggerPool(const RemoteLoggerPool&) = delete;
36
  RemoteLoggerPool(RemoteLoggerPool&&) = delete;
37
  RemoteLoggerPool& operator=(const RemoteLoggerPool&) = delete;
38
  RemoteLoggerPool& operator=(RemoteLoggerPool&&) = delete;
39
  [[nodiscard]] RemoteLoggerInterface::Result queueData(const std::string& data) override;
40
41
  [[nodiscard]] std::string address() const override
42
0
  {
43
0
    return "";
44
0
  }
45
46
  [[nodiscard]] std::string name() const override
47
0
  {
48
0
    return "Pool of " + std::to_string(d_pool.size()) + " loggers";
49
0
  }
50
51
  [[nodiscard]] std::string toString() override;
52
53
  [[nodiscard]] RemoteLoggerInterface::Stats getStats() override
54
0
  {
55
0
    Stats total_stats;
56
0
    for (auto& logger : d_pool) {
57
0
      total_stats += logger->getStats();
58
0
    }
59
0
    return total_stats;
60
0
  }
61
62
private:
63
  std::vector<std::shared_ptr<RemoteLoggerInterface>> d_pool;
64
  std::atomic<size_t> d_counter;
65
};