LCOV - code coverage report
Current view: top level - model - Configuration.hpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 65.1 % 43 28
Test Date: 2026-04-17 17:21:26 Functions: 64.3 % 14 9

            Line data    Source code
       1              : /*
       2              :  ___________________________________________
       3              : |    _     ___                        _     |
       4              : |   | |   |__ \                      | |    |
       5              : |   | |__    ) |__ _  __ _  ___ _ __ | |_   |
       6              : |   | '_ \  / // _` |/ _` |/ _ \ '_ \| __|  |  HTTP/2 AGENT FOR MOCK TESTING
       7              : |   | | | |/ /| (_| | (_| |  __/ | | | |_   |  Version 0.0.z
       8              : |   |_| |_|____\__,_|\__, |\___|_| |_|\__|  |  https://github.com/testillano/h2agent
       9              : |                     __/ |                 |
      10              : |                    |___/                  |
      11              : |___________________________________________|
      12              : 
      13              : Licensed under the MIT License <http://opensource.org/licenses/MIT>.
      14              : SPDX-License-Identifier: MIT
      15              : Copyright (c) 2021 Eduardo Ramos
      16              : 
      17              : Permission is hereby  granted, free of charge, to any  person obtaining a copy
      18              : of this software and associated  documentation files (the "Software"), to deal
      19              : in the Software  without restriction, including without  limitation the rights
      20              : to  use, copy,  modify, merge,  publish, distribute,  sublicense, and/or  sell
      21              : copies  of  the Software,  and  to  permit persons  to  whom  the Software  is
      22              : furnished to do so, subject to the following conditions:
      23              : 
      24              : The above copyright notice and this permission notice shall be included in all
      25              : copies or substantial portions of the Software.
      26              : 
      27              : THE SOFTWARE  IS PROVIDED "AS  IS", WITHOUT WARRANTY  OF ANY KIND,  EXPRESS OR
      28              : IMPLIED,  INCLUDING BUT  NOT  LIMITED TO  THE  WARRANTIES OF  MERCHANTABILITY,
      29              : FITNESS FOR  A PARTICULAR PURPOSE AND  NONINFRINGEMENT. IN NO EVENT  SHALL THE
      30              : AUTHORS  OR COPYRIGHT  HOLDERS  BE  LIABLE FOR  ANY  CLAIM,  DAMAGES OR  OTHER
      31              : LIABILITY, WHETHER IN AN ACTION OF  CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      32              : OUT OF OR IN CONNECTION WITH THE SOFTWARE  OR THE USE OR OTHER DEALINGS IN THE
      33              : SOFTWARE.
      34              : */
      35              : 
      36              : #pragma once
      37              : 
      38              : #include <nlohmann/json.hpp>
      39              : 
      40              : #include <Configuration.hpp>
      41              : 
      42              : 
      43              : namespace h2agent
      44              : {
      45              : namespace model
      46              : {
      47              : 
      48              : /**
      49              :  * This class stores general process static configuration
      50              :  */
      51              : class Configuration
      52              : {
      53              :     unsigned int long_term_files_close_delay_us_{};
      54              :     unsigned int short_term_files_close_delay_us_{};
      55              :     bool lazy_client_connection_{};
      56              :     unsigned int traffic_server_worker_threads_{};
      57              :     unsigned int traffic_server_max_worker_threads_{};
      58              :     int queue_dispatcher_max_size_{};
      59              :     unsigned int traffic_client_connections_{};
      60              :     bool disable_metrics_{};
      61              : 
      62              : public:
      63              :     /**
      64              :     * Constructor
      65              :     */
      66          276 :     Configuration() {
      67          276 :         long_term_files_close_delay_us_ = 1000000; // 1 second
      68          276 :         short_term_files_close_delay_us_ = 0; // instant close
      69          276 :         lazy_client_connection_ = false;
      70          276 :         traffic_server_worker_threads_ = 1;
      71          276 :         traffic_server_max_worker_threads_ = 1;
      72          276 :         queue_dispatcher_max_size_ = -1;
      73          276 :         traffic_client_connections_ = 1;
      74          276 :         disable_metrics_ = false;
      75          276 :     }
      76              : 
      77              :     /**
      78              :     * Destructor
      79              :     */
      80          276 :     ~Configuration() {;}
      81              : 
      82              :     /**
      83              :      * Set long-term files category close delay (microseconds)
      84              :      *
      85              :      * @param usecs close delay in microseconds for long-term files category
      86              :      */
      87            1 :     void setLongTermFilesCloseDelayUsecs(unsigned int usecs) {
      88            1 :         long_term_files_close_delay_us_ = usecs;
      89            1 :     }
      90              : 
      91              :     /**
      92              :      * Set short-term files category close delay (microseconds)
      93              :      *
      94              :      * @param usecs close delay in microseconds for short-term files category
      95              :      */
      96            1 :     void setShortTermFilesCloseDelayUsecs(unsigned int usecs) {
      97            1 :         short_term_files_close_delay_us_ = usecs;
      98            1 :     }
      99              : 
     100              :     /**
     101              :      * Set lazy client connection
     102              :      *
     103              :      * @param lazy Lazy client connection boolean
     104              :      */
     105           17 :     void setLazyClientConnection(bool lazy) {
     106           17 :         lazy_client_connection_ = lazy;
     107           17 :     }
     108              : 
     109              :     /**
     110              :      * Get long-term files category close delay (microseconds)
     111              :      *
     112              :      * @return usecs close delay in microseconds for long-term files category
     113              :      */
     114            4 :     unsigned int getLongTermFilesCloseDelayUsecs() const {
     115            4 :         return long_term_files_close_delay_us_;
     116              :     }
     117              : 
     118              :     /**
     119              :      * Get short-term files category close delay (microseconds)
     120              :      *
     121              :      * @return usecs close delay in microseconds for short-term files category
     122              :      */
     123            2 :     unsigned int getShortTermFilesCloseDelayUsecs() const {
     124            2 :         return short_term_files_close_delay_us_;
     125              :     }
     126              : 
     127              :     /**
     128              :      * Get lazy client connection
     129              :      *
     130              :      * @return Lazy client connection boolean
     131              :      */
     132           19 :     bool getLazyClientConnection() const {
     133           19 :         return lazy_client_connection_;
     134              :     }
     135              : 
     136              :     /**
     137              :      * Set traffic server worker threads
     138              :      *
     139              :      * @param threads Number of server worker threads
     140              :      */
     141            0 :     void setTrafficServerWorkerThreads(unsigned int threads) {
     142            0 :         traffic_server_worker_threads_ = threads;
     143            0 :     }
     144              : 
     145              :     /**
     146              :      * Get traffic server worker threads
     147              :      *
     148              :      * @return Number of server worker threads
     149              :      */
     150              :     unsigned int getTrafficServerWorkerThreads() const {
     151              :         return traffic_server_worker_threads_;
     152              :     }
     153              : 
     154            0 :     void setTrafficServerMaxWorkerThreads(unsigned int threads) {
     155            0 :         traffic_server_max_worker_threads_ = threads;
     156            0 :     }
     157              : 
     158              :     unsigned int getTrafficServerMaxWorkerThreads() const {
     159              :         return traffic_server_max_worker_threads_;
     160              :     }
     161              : 
     162            0 :     void setQueueDispatcherMaxSize(int size) {
     163            0 :         queue_dispatcher_max_size_ = size;
     164            0 :     }
     165              : 
     166              :     int getQueueDispatcherMaxSize() const {
     167              :         return queue_dispatcher_max_size_;
     168              :     }
     169              : 
     170              :     /**
     171              :      * Set traffic client worker threads
     172              :      *
     173              :      * @param connections Number of HTTP/2 connections per client endpoint
     174              :      */
     175            0 :     void setTrafficClientConnections(unsigned int connections) {
     176            0 :         traffic_client_connections_ = connections;
     177            0 :     }
     178              : 
     179              :     /**
     180              :      * Get traffic client connections per endpoint
     181              :      *
     182              :      * @return Number of HTTP/2 connections per client endpoint
     183              :      */
     184            5 :     unsigned int getTrafficClientConnections() const {
     185            5 :         return traffic_client_connections_;
     186              :     }
     187              : 
     188            0 :     void setDisableMetrics(bool disable) {
     189            0 :         disable_metrics_ = disable;
     190            0 :     }
     191              : 
     192              :     bool getDisableMetrics() const {
     193              :         return disable_metrics_;
     194              :     }
     195              : 
     196              :     /**
     197              :      * Json string representation for class information (json object)
     198              :      *
     199              :      * @return Json string representation
     200              :      */
     201              :     std::string asJsonString() const;
     202              : 
     203              :     /**
     204              :      * Builds json document for class information
     205              :      *
     206              :      * @return Json object
     207              :      */
     208              :     nlohmann::json getJson() const;
     209              : };
     210              : 
     211              : }
     212              : }
     213              : 
        

Generated by: LCOV version 2.0-1