]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Config.h
Prep for merge from trunk: undo branch r13313, r13312, and r13311 that were
[thirdparty/squid.git] / src / adaptation / Config.h
1 #ifndef SQUID_ADAPTATION__CONFIG_H
2 #define SQUID_ADAPTATION__CONFIG_H
3
4 #include "acl/forward.h"
5 #include "adaptation/Elements.h"
6 #include "adaptation/forward.h"
7 #include "base/AsyncCall.h"
8 #include "event.h"
9 #include "Notes.h"
10 #include "SquidString.h"
11
12 class ConfigParser;
13 class HttpRequest;
14 class HttpReply;
15
16 namespace Adaptation
17 {
18
19 class Config
20 {
21 public:
22 static void Finalize(bool enable);
23
24 static void ParseServiceSet(void);
25 static void ParseServiceChain(void);
26
27 static void ParseAccess(ConfigParser &parser);
28 static void FreeAccess(void);
29 static void DumpAccess(StoreEntry *, const char *);
30
31 friend class AccessCheck;
32
33 public:
34 static bool Enabled; // true if at least one adaptation mechanism is
35
36 // these are global squid.conf options, documented elsewhere
37 static char *masterx_shared_name; // global TODO: do we need TheConfig?
38 static int service_iteration_limit;
39 static int send_client_ip;
40 static int send_username;
41 static int use_indirect_client;
42
43 // Options below are accessed via Icap::TheConfig or Ecap::TheConfig
44 // TODO: move ICAP-specific options to Icap::Config and add TheConfig
45 int onoff;
46 int service_failure_limit;
47 time_t oldest_service_failure;
48 int service_revival_delay;
49
50 static Notes metaHeaders; ///< The list of configured meta headers
51
52 static bool needHistory; ///< HttpRequest adaptation history should recorded
53
54 typedef std::vector<ServiceConfigPointer> ServiceConfigs;
55 ServiceConfigs serviceConfigs;
56
57 Config();
58 virtual ~Config();
59
60 void parseService(void);
61 void freeService(void);
62 void dumpService(StoreEntry *, const char *) const;
63 ServiceConfigPointer findServiceConfig(const String&);
64
65 /**
66 * Creates and starts the adaptation services. In the case the adaptation
67 * mechanism is disabled then removes any reference to the services from
68 * access rules and service groups, and returns false.
69 * \return true if the services are ready and running, false otherwise
70 */
71 virtual bool finalize();
72
73 protected:
74 /// Removes any reference to the services from configuration
75 virtual void clear();
76
77 /// creates service configuration object that will parse and keep cfg info
78 virtual ServiceConfig *newServiceConfig() const;
79
80 /// Removes the given service from all service groups.
81 void removeService(const String& service);
82
83 /// Removes access rules of the given service or group
84 void removeRule(const String& id);
85
86 private:
87 Config(const Config &); // unsupported
88 Config &operator =(const Config &); // unsupported
89
90 virtual ServicePointer createService(const ServiceConfigPointer &cfg) = 0;
91
92 static void ParseServiceGroup(ServiceGroupPointer group);
93 static void FreeServiceGroups(void);
94 static void DumpServiceGroups(StoreEntry *, const char *);
95 };
96
97 } // namespace Adaptation
98
99 #endif /* SQUID_ADAPTATION__CONFIG_H */