Launcher.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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 
9 #ifndef SQUID_ICAPLAUNCHER_H
10 #define SQUID_ICAPLAUNCHER_H
11 
13 #include "adaptation/Initiate.h"
14 #include "adaptation/Initiator.h"
15 
16 /*
17  * The ICAP Launcher starts an ICAP transaction. If the transaction fails
18  * due to what looks like a persistent connection race condition, the launcher
19  * starts a new ICAP transaction using a freshly opened connection.
20  *
21  * ICAPLauncher and one or more ICAP transactions initiated by it form an
22  * ICAP "query".
23  *
24  * An ICAP Initiator deals with the ICAP Launcher and not an individual ICAP
25  * transaction because the latter may disappear and be replaced by another
26  * transaction.
27  *
28  * Specific ICAP launchers implement the createXaction() method to create
29  * REQMOD, RESPMOD, or OPTIONS transaction from initiator-supplied data.
30  *
31  * TODO: This class might be the right place to initiate ICAP ACL checks or
32  * implement more sophisticated ICAP transaction handling like chaining of
33  * ICAP transactions.
34  */
35 
36 namespace Adaptation
37 {
38 namespace Icap
39 {
40 
41 class Xaction;
42 class XactAbortInfo;
43 
44 // Note: Initiate must be the first parent for cbdata to work. We use
45 // a temporary InitaitorHolder/toCbdata hacks and do not call cbdata
46 // operations on the initiator directly.
48 {
49 public:
50  Launcher(const char *aTypeName, Adaptation::ServicePointer &aService);
51  virtual ~Launcher();
52 
53  // Adaptation::Initiate: asynchronous communication with the initiator
54  void noteInitiatorAborted();
55 
56  // Adaptation::Initiator: asynchronous communication with the current transaction
57  virtual void noteAdaptationAnswer(const Answer &answer);
58  virtual void noteXactAbort(XactAbortInfo info);
59 
60 private:
61  bool canRetry(XactAbortInfo &info) const; //< true if can retry in the case of persistent connection failures
62  bool canRepeat(XactAbortInfo &info) const; //< true if can repeat in the case of no or unsatisfactory response
63 
64 protected:
65  // Adaptation::Initiate API implementation
66  virtual void start();
67  virtual bool doneAll() const;
68  virtual void swanSong();
69 
70  // creates the right ICAP transaction using stored configuration params
71  virtual Xaction *createXaction() = 0;
72 
73  void launchXaction(const char *xkind);
74 
77  int theLaunches; // the number of transaction launches
78 };
79 
83 {
84 public:
85  XactAbortInfo(HttpRequest *anIcapRequest, HttpReply *anIcapReply,
86  bool beRetriable, bool beRepeatable);
89 
90  std::ostream &print(std::ostream &os) const {
91  return os << isRetriable << ',' << isRepeatable;
92  }
93 
98 
99 private:
100  XactAbortInfo &operator =(const XactAbortInfo &); // undefined
101 };
102 
103 inline
104 std::ostream &
105 operator <<(std::ostream &os, const XactAbortInfo &xai)
106 {
107  return xai.print(os);
108 }
109 
110 } // namespace Icap
111 } // namespace Adaptation
112 
113 #endif /* SQUID_ICAPLAUNCHER_H */
114 
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition: Answer.h:22
bool canRepeat(XactAbortInfo &info) const
Definition: Launcher.cc:123
virtual void noteAdaptationAnswer(const Answer &answer)
Definition: Launcher.cc:60
std::ostream & operator<<(std::ostream &os, const XactAbortInfo &xai)
Definition: Launcher.h:105
virtual bool doneAll() const
whether positive goal has been reached
Definition: Launcher.cc:100
std::ostream & print(std::ostream &os) const
Definition: Launcher.h:90
Launcher(const char *aTypeName, Adaptation::ServicePointer &aService)
Definition: Launcher.cc:22
virtual void swanSong()
Definition: Launcher.cc:105
void launchXaction(const char *xkind)
Definition: Launcher.cc:43
XactAbortInfo(HttpRequest *anIcapRequest, HttpReply *anIcapReply, bool beRetriable, bool beRepeatable)
Definition: Launcher.cc:155
virtual Xaction * createXaction()=0
Adaptation::ServicePointer theService
ICAP service for all launches.
Definition: Launcher.h:75
virtual void noteXactAbort(XactAbortInfo info)
Definition: Launcher.cc:81
XactAbortInfo & operator=(const XactAbortInfo &)
virtual void start()
called by AsyncStart; do not call directly
Definition: Launcher.cc:35
bool canRetry(XactAbortInfo &info) const
Definition: Launcher.cc:116
CbcPointer< Initiate > theXaction
current ICAP transaction
Definition: Launcher.h:76

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors