]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/History.h
1 #ifndef SQUID_ADAPT_HISTORY_H
2 #define SQUID_ADAPT_HISTORY_H
5 #include "HttpHeader.h"
7 #include "SquidString.h"
13 /// collects information about adaptations related to a master transaction
14 class History
: public RefCountable
17 typedef RefCount
<Adaptation::History
> Pointer
;
21 /// record the start of a xact, return xact history ID
22 int recordXactStart(const String
&serviceId
, const timeval
&when
, bool retrying
);
24 /// record the end of a xact identified by its history ID
25 void recordXactFinish(int hid
);
27 /// dump individual xaction times to a string
28 void allLogString(const char *serviceId
, String
&buf
);
30 /// dump xaction times, merging retried and retry times together
31 void sumLogString(const char *serviceId
, String
&buf
);
33 /// sets or resets a cross-transactional database record
34 void updateXxRecord(const char *name
, const String
&value
);
36 /// returns true and fills the record fields iff there is a db record
37 bool getXxRecord(String
&name
, String
&value
) const;
39 /// sets or resets next services for the Adaptation::Iterator to notice
40 void updateNextServices(const String
&services
);
42 /// returns true, fills the value, and resets iff next services were set
43 bool extractNextServices(String
&value
);
45 /// store the last meta header fields received from the adaptation service
46 void recordMeta(const HttpHeader
*lm
);
49 /// Last received meta header (REQMOD or RESPMOD, whichever comes last).
51 /// All REQMOD and RESPMOD meta headers merged. Last field wins conflicts.
55 /// single Xaction stats (i.e., a historical record entry)
59 Entry(const String
&serviceId
, const timeval
&when
);
60 Entry(); // required by Vector<>
62 void stop(); ///< updates stats on transaction end
63 int rptm(); ///< returns response time [msec], calculates it if needed
65 String service
; ///< adaptation service ID
66 timeval start
; ///< when the xaction was started
69 int theRptm
; ///< calculated and cached response time value in msec
72 bool retried
; ///< whether the xaction was replaced by another
75 typedef Vector
<Entry
> Entries
;
76 Entries theEntries
; ///< historical record, in the order of xact starts
78 // theXx* will become a map<string,string>, but we only support one record
79 String theXxName
; ///< name part of the cross-transactional database record
80 String theXxValue
; ///< value part of the cross-xactional database record
82 String theNextServices
; ///< services Adaptation::Iterator must use next
85 } // namespace Adaptation