XactionRep.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 /* DEBUG: section 93 eCAP Interface */
10 
11 #ifndef SQUID_SRC_ADAPTATION_ECAP_XACTIONREP_H
12 #define SQUID_SRC_ADAPTATION_ECAP_XACTIONREP_H
13 
16 #include "adaptation/Initiate.h"
17 #include "adaptation/Message.h"
18 #include "BodyPipe.h"
19 
20 #if HAVE_LIBECAP_ADAPTER_XACTION_H
21 #include <libecap/adapter/xaction.h>
22 #endif
23 #if HAVE_LIBECAP_HOST_XACTION_H
24 #include <libecap/host/xaction.h>
25 #endif
26 
27 namespace Adaptation
28 {
29 namespace Ecap
30 {
31 
32 /* The eCAP xaction representative maintains information about a single eCAP
33  xaction that Squid communicates with. One eCAP module may register many
34  eCAP xactions. */
35 class XactionRep : public Adaptation::Initiate, public libecap::host::Xaction,
36  public BodyConsumer, public BodyProducer
37 {
39 
40 public:
42  ~XactionRep() override;
43 
44  typedef libecap::shared_ptr<libecap::adapter::Xaction> AdapterXaction;
45  void master(const AdapterXaction &aMaster); // establish a link
46 
47  // libecap::host::Xaction API
48  const libecap::Area option(const libecap::Name &name) const override;
49  void visitEachOption(libecap::NamedValueVisitor &visitor) const override;
50  libecap::Message &virgin() override;
51  const libecap::Message &cause() override;
52  libecap::Message &adapted() override;
53  void useVirgin() override;
54  void useAdapted(const libecap::shared_ptr<libecap::Message> &msg) override;
55  void blockVirgin() override;
56  void adaptationDelayed(const libecap::Delay &) override;
57  void adaptationAborted() override;
58  void resume() override;
59  void vbDiscard() override;
60  void vbMake() override;
61  void vbStopMaking() override;
62  void vbMakeMore() override;
63  libecap::Area vbContent(libecap::size_type offset, libecap::size_type size) override;
64  void vbContentShift(libecap::size_type size) override;
65  void noteAbContentDone(bool atEnd) override;
66  void noteAbContentAvailable() override;
67 
68  // BodyProducer API
71 
72  // BodyConsumer API
76 
77  // Initiate API
78  void noteInitiatorAborted() override;
79 
80  // AsyncJob API (via Initiate)
81  void start() override;
82  bool doneAll() const override;
83  void swanSong() override;
84  const char *status() const override;
85 
86 protected:
87  Service &service();
88 
90 
91  void sinkVb(const char *reason);
92  void preserveVb(const char *reason);
93  void forgetVb(const char *reason);
94 
95  void moveAbContent();
96 
98  void terminateMaster();
99  void scheduleStop(const char *reason);
101 
102  const libecap::Area clientIpValue() const;
103  const libecap::Area usernameValue() const;
104  const libecap::Area masterxSharedValue(const libecap::Name &name) const;
106  const libecap::Area metaValue(const libecap::Name &name) const;
108  void visitEachMetaHeader(libecap::NamedValueVisitor &visitor) const;
109 
110  void doResume();
111 
112 private:
113  AdapterXaction theMaster; // the actual adaptation xaction we represent
115 
118 
119  typedef libecap::shared_ptr<libecap::Message> MessagePtr;
121 
123  OperationState makingVb; //< delivering virgin body from pipe to adapter
124  OperationState proxyingAb; // delivering adapted body from adapter to core
126  bool vbProductionFinished; // whether there can be no more vb bytes
127  bool abProductionFinished; // whether adapter has finished producing ab
128  bool abProductionAtEnd; // whether adapter produced a complete ab
130 };
131 
132 } // namespace Ecap
133 } // namespace Adaptation
134 
135 #endif /* SQUID_SRC_ADAPTATION_ECAP_XACTIONREP_H */
136 
void visitEachOption(libecap::NamedValueVisitor &visitor) const override
Definition: XactionRep.cc:111
void useAdapted(const libecap::shared_ptr< libecap::Message > &msg) override
Definition: XactionRep.cc:421
libecap::Message & virgin() override
Definition: XactionRep.cc:312
Adaptation::ServicePointer theService
xaction's adaptation service
Definition: XactionRep.h:114
common parts of HttpRequest and HttpReply
Definition: Message.h:25
void noteBodyProducerAborted(RefCount< BodyPipe > bp) override
Definition: XactionRep.cc:668
libecap::Area vbContent(libecap::size_type offset, libecap::size_type size) override
Definition: XactionRep.cc:553
const libecap::Area option(const libecap::Name &name) const override
Definition: XactionRep.cc:95
void sinkVb(const char *reason)
Definition: XactionRep.cc:358
bool doneAll() const override
whether positive goal has been reached
Definition: XactionRep.cc:350
void updateSources(Http::Message *adapted)
Definition: XactionRep.cc:743
void preserveVb(const char *reason)
Definition: XactionRep.cc:372
const char * status() const override
internal cleanup; do not call directly
Definition: XactionRep.cc:700
const libecap::Message & cause() override
Definition: XactionRep.cc:318
void noteAbContentDone(bool atEnd) override
Definition: XactionRep.cc:591
void vbMakeMore() override
Definition: XactionRep.cc:543
void noteMoreBodyDataAvailable(RefCount< BodyPipe > bp) override
Definition: XactionRep.cc:651
const libecap::Area clientIpValue() const
Definition: XactionRep.cc:130
int size
Definition: ModDevPoll.cc:69
int adaptHistoryId
adaptation history slot reservation
Definition: XactionRep.h:125
void blockVirgin() override
Definition: XactionRep.cc:451
void start() override
called by AsyncStart; do not call directly
Definition: XactionRep.cc:231
libecap::shared_ptr< libecap::adapter::Xaction > AdapterXaction
Definition: XactionRep.h:44
XactionRep(Http::Message *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, const Adaptation::ServicePointer &service)
Definition: XactionRep.cc:55
void noteBodyConsumerAborted(RefCount< BodyPipe > bp) override
Definition: XactionRep.cc:641
const libecap::Area usernameValue() const
Definition: XactionRep.cc:155
void noteAbContentAvailable() override
Definition: XactionRep.cc:601
void noteInitiatorAborted() override
Definition: XactionRep.cc:677
void vbStopMaking() override
Definition: XactionRep.cc:534
AccessLogEntry::Pointer al
Master transaction AccessLogEntry.
Definition: XactionRep.h:129
void updateHistory(Http::Message *adapted)
Definition: XactionRep.cc:467
const libecap::Area masterxSharedValue(const libecap::Name &name) const
Definition: XactionRep.cc:173
void visitEachMetaHeader(libecap::NamedValueVisitor &visitor) const
Return the adaptation meta headers and their values.
Definition: XactionRep.cc:213
void forgetVb(const char *reason)
Definition: XactionRep.cc:388
void master(const AdapterXaction &aMaster)
Definition: XactionRep.cc:80
void adaptationAborted() override
Definition: XactionRep.cc:627
const libecap::Area metaValue(const libecap::Name &name) const
Return the adaptation meta header value for the given header "name".
Definition: XactionRep.cc:190
void vbContentShift(libecap::size_type size) override
Definition: XactionRep.cc:577
Adaptation::Message & answer()
Definition: XactionRep.cc:332
void noteBodyProductionEnded(RefCount< BodyPipe > bp) override
Definition: XactionRep.cc:659
void scheduleStop(const char *reason)
libecap::Message & adapted() override
Definition: XactionRep.cc:325
libecap::shared_ptr< libecap::Message > MessagePtr
Definition: XactionRep.h:119
void adaptationDelayed(const libecap::Delay &) override
Definition: XactionRep.cc:619
void noteMoreBodySpaceAvailable(RefCount< BodyPipe > bp) override
Definition: XactionRep.cc:634

 

Introduction

Documentation

Support

Miscellaneous