]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 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 | ||
a68cf076 AR |
9 | #ifndef SQUID_ADAPTATION__SERVICE_H |
10 | #define SQUID_ADAPTATION__SERVICE_H | |
11 | ||
af0ded40 | 12 | #include "AccessLogEntry.h" |
a68cf076 | 13 | #include "adaptation/Elements.h" |
602d9612 | 14 | #include "adaptation/forward.h" |
d81a31f1 | 15 | #include "adaptation/ServiceConfig.h" |
8bf217bd | 16 | #include "base/RefCount.h" |
63df1d28 | 17 | #include "http/forward.h" |
602d9612 | 18 | #include "SquidString.h" |
d81a31f1 AR |
19 | |
20 | // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them | |
21 | ||
26ac0430 AJ |
22 | namespace Adaptation |
23 | { | |
a68cf076 AR |
24 | |
25 | // manages adaptation service configuration in squid.conf | |
26 | // specific adaptation mechanisms extend this class | |
d81a31f1 | 27 | class Service: public RefCountable |
a68cf076 AR |
28 | { |
29 | public: | |
d81a31f1 | 30 | typedef RefCount<Service> Pointer; |
62c7f90e | 31 | typedef String Id; |
d81a31f1 AR |
32 | |
33 | public: | |
6666da11 | 34 | explicit Service(const ServiceConfigPointer &aConfig); |
a68cf076 AR |
35 | virtual ~Service(); |
36 | ||
d81a31f1 | 37 | virtual bool probed() const = 0; // see comments above |
201438ac | 38 | virtual bool broken() const; |
d81a31f1 | 39 | virtual bool up() const = 0; // see comments above |
a68cf076 | 40 | |
63df1d28 | 41 | virtual Initiate *makeXactLauncher(Http::Message *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp) = 0; |
a68cf076 | 42 | |
a22e6cd3 AR |
43 | bool wants(const ServiceFilter &filter) const; |
44 | ||
d81a31f1 | 45 | // the methods below can only be called on an up() service |
51b5dcf5 | 46 | virtual bool wantsUrl(const SBuf &urlPath) const = 0; |
d81a31f1 AR |
47 | |
48 | // called by transactions to report service failure | |
49 | virtual void noteFailure() = 0; | |
50 | ||
e1e90d26 | 51 | const ServiceConfig &cfg() const { return *theConfig; } |
a68cf076 | 52 | |
62c7f90e AR |
53 | virtual void finalize(); // called after creation |
54 | ||
76fc7e57 AJ |
55 | /// called when removed from the config; the service will be |
56 | /// auto-destroyed when the last refcounting user leaves | |
57 | virtual void detach() = 0; | |
58 | /// whether detached() was called | |
59 | virtual bool detached() const = 0; | |
60 | ||
a68cf076 | 61 | protected: |
e1e90d26 | 62 | ServiceConfig &writeableCfg() { return *theConfig; } |
d81a31f1 AR |
63 | |
64 | private: | |
e1e90d26 | 65 | ServiceConfigPointer theConfig; |
a68cf076 AR |
66 | }; |
67 | ||
d81a31f1 AR |
68 | typedef Service::Pointer ServicePointer; |
69 | ||
c8ea3cc0 | 70 | typedef std::vector<Adaptation::ServicePointer> Services; |
82afb125 FC |
71 | Services &AllServices(); |
72 | ServicePointer FindService(const Service::Id &key); | |
62c7f90e | 73 | |
76fc7e57 | 74 | /// detach all adaptation services from current configuration |
82afb125 | 75 | void DetachServices(); |
76fc7e57 | 76 | |
a68cf076 AR |
77 | } // namespace Adaptation |
78 | ||
79 | #endif /* SQUID_ADAPTATION__SERVICE_H */ | |
f53969cc | 80 |