Iterator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_ADAPTATION_ITERATOR_H
10 #define SQUID_SRC_ADAPTATION_ITERATOR_H
11 
12 #include "adaptation/Initiate.h"
13 #include "adaptation/Initiator.h"
15 #include "http/forward.h"
16 #include "log/forward.h"
17 
18 namespace Adaptation
19 {
20 
21 /* Iterator is started by client or server Initiators. It iterates services
22  in a given group, starting transaction launcher for each service, according
23  to the service plan. Service plans support adaptation sets and chains.
24 
25  Note: Initiate must be the first parent for cbdata to work. We use
26  a temporary InitiatorHolder/toCbdata hacks and do not call cbdata
27  operations on the initiator directly.
28 */
29 
31 class Iterator: public Initiate, public Initiator
32 {
34 
35 public:
36  Iterator(Http::Message *virginHeader, HttpRequest *virginCause,
37  const AccessLogEntryPointer &,
38  const Adaptation::ServiceGroupPointer &aGroup);
39  ~Iterator() override;
40 
41  // Adaptation::Initiate: asynchronous communication with the initiator
42  void noteInitiatorAborted() override;
43 
44  // Adaptation::Initiator: asynchronous communication with the current launcher
45  void noteAdaptationAnswer(const Answer &answer) override;
46 
47 protected:
48  // Adaptation::Initiate API implementation
49  void start() override;
50  bool doneAll() const override;
51  void swanSong() override;
52 
54  void step();
55 
57  bool updatePlan(bool adopt); // returns true iff the plan was replaced
58 
60  ServiceFilter filter() const;
61 
63  void handleAdaptationBlock(const Answer &answer);
64  void handleAdaptationError(bool final);
65 
72  int iterations;
73  bool adapted;
74 };
75 
76 } // namespace Adaptation
77 
78 #endif /* SQUID_SRC_ADAPTATION_ITERATOR_H */
79 
ServiceGroupPointer theGroup
the service group we are iterating
Definition: Iterator.h:66
void swanSong() override
Definition: Iterator.cc:215
void step()
launches adaptation for the service selected by the plan
Definition: Iterator.cc:71
common parts of HttpRequest and HttpReply
Definition: Message.h:25
~Iterator() override
Definition: Iterator.cc:43
bool adapted
whether the virgin message has been replaced
Definition: Iterator.h:73
information used to search for adaptation services
Definition: ServiceFilter.h:22
Iterator(Http::Message *virginHeader, HttpRequest *virginCause, const AccessLogEntryPointer &, const Adaptation::ServiceGroupPointer &aGroup)
Definition: Iterator.cc:22
void noteAdaptationAnswer(const Answer &answer) override
Definition: Iterator.cc:115
int iterations
number of steps initiated
Definition: Iterator.h:72
void handleAdaptationError(bool final)
Definition: Iterator.cc:175
bool doneAll() const override
whether positive goal has been reached
Definition: Iterator.cc:210
void start() override
called by AsyncStart; do not call directly
Definition: Iterator.cc:50
iterates services in ServiceGroup, starting adaptation launchers
Definition: Iterator.h:31
void handleAdaptationBlock(const Answer &answer)
Definition: Iterator.cc:166
bool updatePlan(bool adopt)
replace the current group and plan with service-proposed ones if needed
Definition: Iterator.cc:226
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition: Answer.h:24
HttpRequest * theCause
the cause of the original virgin message
Definition: Iterator.h:69
ServicePlan thePlan
which services to use and in what order
Definition: Iterator.h:67
ServiceFilter filter() const
creates service filter for the current step
Definition: Iterator.cc:266
AccessLogEntryPointer al
info for the future access.log entry
Definition: Iterator.h:70
CbcPointer< Adaptation::Initiate > theLauncher
current transaction launcher
Definition: Iterator.h:71
void handleAdaptedHeader(Http::Message *msg)
Definition: Iterator.cc:133
Http::Message * theMsg
the message being adapted (virgin for each step)
Definition: Iterator.h:68
void noteInitiatorAborted() override
Definition: Iterator.cc:159

 

Introduction

Documentation

Support

Miscellaneous