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