]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
ff9d9458 FC |
9 | #ifndef SQUID_SRC_CLIENTDELAYCONFIG_H |
10 | #define SQUID_SRC_CLIENTDELAYCONFIG_H | |
14a7bbc7 | 11 | |
6f58d7d7 | 12 | #include "acl/forward.h" |
b27668ec | 13 | #include "base/RefCount.h" |
b181c1df | 14 | |
c8ea3cc0 | 15 | #include <vector> |
08f774de | 16 | |
14a7bbc7 | 17 | class StoreEntry; |
14a7bbc7 CT |
18 | class ConfigParser; |
19 | ||
20 | /// \ingroup DelayPoolsAPI | |
21 | ||
22 | /* represents one client write limiting delay 'pool' */ | |
b27668ec | 23 | class ClientDelayPool : public RefCountable |
14a7bbc7 CT |
24 | { |
25 | public: | |
b27668ec EB |
26 | typedef RefCount<ClientDelayPool> Pointer; |
27 | ||
14a7bbc7 | 28 | ClientDelayPool() |
b27668ec | 29 | : access(nullptr), rate(0), highwatermark(0) {} |
337b9aa4 | 30 | ~ClientDelayPool() override; |
b27668ec EB |
31 | ClientDelayPool(const ClientDelayPool &) = delete; |
32 | ClientDelayPool &operator=(const ClientDelayPool &) = delete; | |
33 | ||
14a7bbc7 CT |
34 | void dump (StoreEntry * entry, unsigned int poolNumberMinusOne) const; |
35 | acl_access *access; | |
36 | int rate; | |
37 | int64_t highwatermark; | |
38 | }; | |
39 | ||
b27668ec EB |
40 | class ClientDelayPools |
41 | { | |
42 | public: | |
43 | ClientDelayPools(const ClientDelayPools &) = delete; | |
44 | ClientDelayPools &operator=(const ClientDelayPools &) = delete; | |
45 | static ClientDelayPools *Instance(); | |
46 | ||
47 | std::vector<ClientDelayPool::Pointer> pools; | |
48 | private: | |
49 | ClientDelayPools() {} | |
50 | ~ClientDelayPools(); | |
51 | }; | |
14a7bbc7 CT |
52 | |
53 | /* represents configuration of client write limiting delay pools */ | |
54 | class ClientDelayConfig | |
55 | { | |
56 | public: | |
57 | ClientDelayConfig() | |
f53969cc | 58 | : initial(50) {} |
b27668ec EB |
59 | ClientDelayConfig(const ClientDelayConfig &) = delete; |
60 | ClientDelayConfig &operator=(const ClientDelayConfig &) = delete; | |
61 | ||
62 | void freePools(); | |
14a7bbc7 CT |
63 | void dumpPoolCount(StoreEntry * entry, const char *name) const; |
64 | /* parsing of client_delay_pools - number of pools */ | |
65 | void parsePoolCount(); | |
66 | /* parsing of client_delay_parameters lines */ | |
67 | void parsePoolRates(); | |
68 | /* parsing client_delay_access lines */ | |
69 | void parsePoolAccess(ConfigParser &parser); | |
70 | ||
71 | void finalize(); ///< checks pools configuration | |
72 | ||
73 | /* initial bucket level, how fill bucket at startup */ | |
74 | unsigned short initial; | |
b27668ec | 75 | |
14a7bbc7 | 76 | private: |
b27668ec EB |
77 | unsigned short parsePoolId(); |
78 | std::vector<ClientDelayPool::Pointer> &pools() { return ClientDelayPools::Instance()->pools; } | |
79 | ClientDelayPool &pool(const int i) { return *(ClientDelayPools::Instance()->pools.at(i)); } | |
14a7bbc7 CT |
80 | }; |
81 | ||
ff9d9458 | 82 | #endif /* SQUID_SRC_CLIENTDELAYCONFIG_H */ |
f53969cc | 83 |