]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/Action.h
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 16 Cache Manager API */
11 #ifndef SQUID_MGR_ACTION_H
12 #define SQUID_MGR_ACTION_H
14 #include "ipc/forward.h"
15 #include "mgr/forward.h"
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).
24 class Action
: public RefCountable
27 typedef RefCount
<Action
> Pointer
;
30 Action(const CommandPointer
&aCmd
);
33 /* for local Cache Manager use */
35 /// collect + fillEntry: collect local information and fill the store entry
36 void run(StoreEntry
*entry
, bool writeHttpHeader
);
38 /// prepare store entry, dump info, close store entry (if possible)
39 void fillEntry(StoreEntry
*entry
, bool writeHttpHeader
);
41 /* for global Coordinator use */
43 /// incrementally merge in remote information (of the same action type)
44 virtual void add(const Action
&action
);
46 /* global-local communication */
48 /// respond to Coordinator request; default is to collect and sendResponse
49 virtual void respond(const Request
&request
);
51 /// pack collected action info into a message to be sent to Coordinator
52 virtual void pack(Ipc::TypedMsgHdr
&msg
) const {}
53 /// unpack action info from the message received by Coordinator
54 virtual void unpack(const Ipc::TypedMsgHdr
&msg
) {}
56 /// notify Coordinator that this action is done with local processing
57 void sendResponse(unsigned int requestId
);
59 /* Action properties */
61 /// whether at least some local kid info can be combined and, hence, the
62 /// combined data should be written at the end of the coordinated response
63 virtual bool aggregatable() const { return true; } // most kid classes are
65 bool atomic() const; ///< dump() call writes everything before returning
66 const char *name() const; ///< label as seen in the cache manager menu
67 const Command
&command() const; ///< the cause of this action
69 StoreEntry
*createStoreEntry() const; ///< creates store entry from params
71 ///< Content-Type: header value for this report
72 virtual const char *contentType() const {return "text/plain;charset=utf-8";}
75 /// calculate and keep local action-specific information
76 virtual void collect() {}
78 /** start writing action-specific info to Store entry;
79 * may collect info during dump, especially if collect() did nothing
80 * non-atomic() actions may continue writing asynchronously after returning
82 virtual void dump(StoreEntry
*entry
) {}
85 const CommandPointer cmd
; ///< the command that caused this action
88 Action(const Action
&); // not implemented
89 Action
&operator= (const Action
&); // not implemented
94 #endif /* SQUID_MGR_ACTION_H */