mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 04:58:21 +00:00
Management framework: add "finish" callback to requests
These callbacks are handy for stringing together codepaths separated by event request/response transactions: when such a transaction completes, the callback allows locating a parent request for the finished one, to continue its processing.
This commit is contained in:
parent
a2525e44ba
commit
8bc142f73c
1 changed files with 11 additions and 0 deletions
|
@ -32,6 +32,14 @@ export {
|
|||
finished: bool &default=F;
|
||||
};
|
||||
|
||||
# To allow a callback to refer to Requests, the Request type must
|
||||
# exist. So redef to add it:
|
||||
redef record Request += {
|
||||
## A callback to invoke when this request is finished via
|
||||
## :zeek:see:`Management::Request::finish`.
|
||||
finish: function(req: Management::Request::Request) &optional;
|
||||
};
|
||||
|
||||
## The timeout interval for request state. Such state (see the
|
||||
## :zeek:see:`Management::Request` module) ties together request and
|
||||
## response event pairs. A timeout causes cleanup of request state if
|
||||
|
@ -131,6 +139,9 @@ function finish(reqid: string): bool
|
|||
local req = g_requests[reqid];
|
||||
delete g_requests[reqid];
|
||||
|
||||
if ( req?$finish )
|
||||
req$finish(req);
|
||||
|
||||
req$finished = T;
|
||||
|
||||
return T;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue