]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/Action.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / Action.h
CommitLineData
8822ebee 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
8822ebee 3 *
bbc27441
AJ
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.
8822ebee
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
8822ebee
AR
11#ifndef SQUID_MGR_ACTION_H
12#define SQUID_MGR_ACTION_H
13
14#include "ipc/forward.h"
15#include "mgr/forward.h"
16
17class StoreEntry;
18
19namespace Mgr
20{
21
22/// Base API for organizing the processing of a compiled cache manager command.
23/// Not a job because all methods are synchronous (but they may start jobs).
24class Action: public RefCountable
25{
26public:
27 typedef RefCount<Action> Pointer;
28
29public:
30 Action(const CommandPointer &aCmd);
31 virtual ~Action();
32
8822ebee
AR
33 /* for local Cache Manager use */
34
35 /// collect + fillEntry: collect local information and fill the store entry
36 void run(StoreEntry *entry, bool writeHttpHeader);
37
38 /// prepare store entry, dump info, close store entry (if possible)
39 void fillEntry(StoreEntry *entry, bool writeHttpHeader);
40
8822ebee
AR
41 /* for global Coordinator use */
42
43 /// incrementally merge in remote information (of the same action type)
44 virtual void add(const Action &action);
45
8822ebee
AR
46 /* global-local communication */
47
48 /// respond to Coordinator request; default is to collect and sendResponse
49 virtual void respond(const Request &request);
50
51 /// pack collected action info into a message to be sent to Coordinator
ced8def3
AJ
52 virtual void pack(Ipc::TypedMsgHdr &) const {}
53
8822ebee 54 /// unpack action info from the message received by Coordinator
ced8def3 55 virtual void unpack(const Ipc::TypedMsgHdr &) {}
8822ebee
AR
56
57 /// notify Coordinator that this action is done with local processing
58 void sendResponse(unsigned int requestId);
59
8822ebee
AR
60 /* Action properties */
61
62 /// whether at least some local kid info can be combined and, hence, the
63 /// combined data should be written at the end of the coordinated response
64 virtual bool aggregatable() const { return true; } // most kid classes are
65
66 bool atomic() const; ///< dump() call writes everything before returning
67 const char *name() const; ///< label as seen in the cache manager menu
68 const Command &command() const; ///< the cause of this action
69
70 StoreEntry *createStoreEntry() const; ///< creates store entry from params
71
8088f8d0
AJ
72 ///< Content-Type: header value for this report
73 virtual const char *contentType() const {return "text/plain;charset=utf-8";}
74
8822ebee
AR
75protected:
76 /// calculate and keep local action-specific information
77 virtual void collect() {}
78
d9fc6862 79 /** start writing action-specific info to Store entry;
8822ebee
AR
80 * may collect info during dump, especially if collect() did nothing
81 * non-atomic() actions may continue writing asynchronously after returning
82 */
ced8def3 83 virtual void dump(StoreEntry *) {}
8822ebee 84
8822ebee
AR
85private:
86 const CommandPointer cmd; ///< the command that caused this action
87
8822ebee
AR
88private:
89 Action(const Action &); // not implemented
90 Action &operator= (const Action &); // not implemented
91};
92
93} // namespace Mgr
94
95#endif /* SQUID_MGR_ACTION_H */
f53969cc 96