]> git.ipfire.org Git - thirdparty/squid.git/blame - src/adaptation/Service.h
Bug #2459 fix, access logging enhancements, ICAP logging and retries support:
[thirdparty/squid.git] / src / adaptation / Service.h
CommitLineData
a68cf076
AR
1#ifndef SQUID_ADAPTATION__SERVICE_H
2#define SQUID_ADAPTATION__SERVICE_H
3
4#include "SquidString.h"
d81a31f1
AR
5#include "RefCount.h"
6#include "adaptation/forward.h"
a68cf076 7#include "adaptation/Elements.h"
d81a31f1
AR
8#include "adaptation/ServiceConfig.h"
9
10// TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them
11
12class HttpMsg;
13class HttpRequest;
a68cf076 14
26ac0430
AJ
15namespace Adaptation
16{
a68cf076
AR
17
18// manages adaptation service configuration in squid.conf
19// specific adaptation mechanisms extend this class
d81a31f1 20class Service: public RefCountable
a68cf076
AR
21{
22public:
d81a31f1 23 typedef RefCount<Service> Pointer;
62c7f90e 24 typedef String Id;
d81a31f1
AR
25
26public:
27 Service(const ServiceConfig &aConfig);
a68cf076
AR
28 virtual ~Service();
29
d81a31f1
AR
30 // call when the service is no longer needed or valid
31 virtual void invalidate() = 0;
a68cf076 32
d81a31f1 33 virtual bool probed() const = 0; // see comments above
201438ac 34 virtual bool broken() const;
d81a31f1 35 virtual bool up() const = 0; // see comments above
a68cf076 36
d81a31f1 37 virtual Initiate *makeXactLauncher(Initiator *, HttpMsg *virginHeader, HttpRequest *virginCause) = 0;
a68cf076 38
d81a31f1
AR
39 typedef void Callback(void *data, Pointer &service);
40 void callWhenReady(Callback *cb, void *data);
41
42 // the methods below can only be called on an up() service
43 virtual bool wantsUrl(const String &urlPath) const = 0;
44
45 // called by transactions to report service failure
46 virtual void noteFailure() = 0;
47
48 const ServiceConfig &cfg() const { return theConfig; }
a68cf076 49
62c7f90e
AR
50 virtual void finalize(); // called after creation
51
a68cf076 52protected:
d81a31f1
AR
53 ServiceConfig &writeableCfg() { return theConfig; }
54
55private:
56 ServiceConfig theConfig;
a68cf076
AR
57};
58
d81a31f1
AR
59typedef Service::Pointer ServicePointer;
60
62c7f90e
AR
61typedef Vector<Adaptation::ServicePointer> Services;
62extern Services &AllServices();
63extern ServicePointer FindService(const Service::Id &key);
64
a68cf076
AR
65} // namespace Adaptation
66
67#endif /* SQUID_ADAPTATION__SERVICE_H */