mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Add expiration mechanism to client request state.
This establishes a timeout controlled via ClusterController::request_timeout, triggering a ClusterController::Request::request_expired event whenever a timeout rolls around before request state has been finalized by a request's normal processing.
This commit is contained in:
parent
fc9679e510
commit
1e823f931e
2 changed files with 23 additions and 4 deletions
|
@ -32,6 +32,9 @@ export {
|
||||||
# controller both redef this. Used during logging.
|
# controller both redef this. Used during logging.
|
||||||
const role = ClusterController::Types::NONE &redef;
|
const role = ClusterController::Types::NONE &redef;
|
||||||
|
|
||||||
|
# The timeout for client request state.
|
||||||
|
const request_timeout = 15sec &redef;
|
||||||
|
|
||||||
# Agent and controller currently log only, not via the data cluster's
|
# Agent and controller currently log only, not via the data cluster's
|
||||||
# logger. (This might get added later.) For now, this means that
|
# logger. (This might get added later.) For now, this means that
|
||||||
# if both write to the same log file, it gets garbled. The following
|
# if both write to the same log file, it gets garbled. The following
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@load ./types
|
@load ./types
|
||||||
|
@load ./config
|
||||||
|
|
||||||
module ClusterController::Request;
|
module ClusterController::Request;
|
||||||
|
|
||||||
|
@ -8,8 +9,10 @@ export {
|
||||||
parent_id: string &optional;
|
parent_id: string &optional;
|
||||||
};
|
};
|
||||||
|
|
||||||
# API-specific state. XXX we may be able to generalize after this
|
# API-specific state. XXX we may be able to generalize after this has
|
||||||
# has settled a bit more.
|
# settled a bit more. It would also be nice to move request-specific
|
||||||
|
# state out of this module -- we could for example redef Request in
|
||||||
|
# main.zeek as needed.
|
||||||
|
|
||||||
# State specific to the set_configuration request/response events
|
# State specific to the set_configuration request/response events
|
||||||
type SetConfigurationState: record {
|
type SetConfigurationState: record {
|
||||||
|
@ -44,12 +47,25 @@ export {
|
||||||
global lookup: function(reqid: string): Request;
|
global lookup: function(reqid: string): Request;
|
||||||
global finish: function(reqid: string): bool;
|
global finish: function(reqid: string): bool;
|
||||||
|
|
||||||
|
global request_expired: event(req: Request);
|
||||||
|
|
||||||
global is_null: function(request: Request): bool;
|
global is_null: function(request: Request): bool;
|
||||||
global to_string: function(request: Request): string;
|
global to_string: function(request: Request): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
# XXX this needs a mechanism for expiring stale requests
|
function requests_expire_func(reqs: table[string] of Request, reqid: string): interval
|
||||||
global g_requests: table[string] of Request;
|
{
|
||||||
|
event ClusterController::Request::request_expired(reqs[reqid]);
|
||||||
|
return 0secs;
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is the global request-tracking table. The table maps from request ID
|
||||||
|
# strings to corresponding Request records. Entries time out after the
|
||||||
|
# ClusterController::request_timeout interval. Upon expiration, a
|
||||||
|
# request_expired event triggers that conveys the request state.
|
||||||
|
global g_requests: table[string] of Request
|
||||||
|
&create_expire=ClusterController::request_timeout
|
||||||
|
&expire_func=requests_expire_func;
|
||||||
|
|
||||||
function create(reqid: string): Request
|
function create(reqid: string): Request
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue