mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
Move redefs of ClusterController::Request::Request to their places of use
The Request module does not need to know about additional state tucked onto it by its users.
This commit is contained in:
parent
f9ac03d6e3
commit
4b5584a85d
3 changed files with 31 additions and 32 deletions
|
@ -15,6 +15,20 @@
|
|||
|
||||
module ClusterController::Runtime;
|
||||
|
||||
# Request state specific to the set_configuration request/response events
|
||||
type SetConfigurationState: record {
|
||||
config: ClusterController::Types::Configuration;
|
||||
requests: set[string] &default=set();
|
||||
};
|
||||
|
||||
# Dummy state for testing events.
|
||||
type TestState: record { };
|
||||
|
||||
redef record ClusterController::Request::Request += {
|
||||
set_configuration_state: SetConfigurationState &optional;
|
||||
test_state: TestState &optional;
|
||||
};
|
||||
|
||||
redef ClusterController::role = ClusterController::Types::CONTROLLER;
|
||||
|
||||
global check_instances_ready: function();
|
||||
|
@ -323,7 +337,7 @@ event ClusterController::API::set_configuration_request(reqid: string, config: C
|
|||
local res: ClusterController::Types::Result;
|
||||
local req = ClusterController::Request::create(reqid);
|
||||
|
||||
req$set_configuration_state = ClusterController::Request::SetConfigurationState($config = config);
|
||||
req$set_configuration_state = SetConfigurationState($config = config);
|
||||
|
||||
# At the moment there can only be one pending request.
|
||||
if ( g_config_reqid_pending != "" )
|
||||
|
@ -486,7 +500,7 @@ event ClusterController::API::test_timeout_request(reqid: string, with_state: bo
|
|||
# This state times out and triggers a timeout response in the
|
||||
# above request_expired event handler.
|
||||
local req = ClusterController::Request::create(reqid);
|
||||
req$test_state = ClusterController::Request::TestState();
|
||||
req$test_state = TestState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,37 +18,13 @@ export {
|
|||
## received by the client), this specifies that original, "parent"
|
||||
## request.
|
||||
parent_id: string &optional;
|
||||
};
|
||||
|
||||
# API-specific state. XXX we may be able to generalize after this has
|
||||
# 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
|
||||
type SetConfigurationState: record {
|
||||
config: ClusterController::Types::Configuration;
|
||||
requests: set[string] &default=set();
|
||||
};
|
||||
|
||||
# State specific to supervisor interactions
|
||||
type SupervisorState: record {
|
||||
node: string;
|
||||
};
|
||||
|
||||
# State for testing events
|
||||
type TestState: record {
|
||||
};
|
||||
|
||||
# The redef is a workaround so we can use the Request type
|
||||
# while it is still being defined.
|
||||
redef record Request += {
|
||||
## The results vector builds up the list of results we eventually
|
||||
## send to the requestor when we have processed the request.
|
||||
results: ClusterController::Types::ResultVec &default=vector();
|
||||
finished: bool &default=F;
|
||||
|
||||
set_configuration_state: SetConfigurationState &optional;
|
||||
supervisor_state: SupervisorState &optional;
|
||||
test_state: TestState &optional;
|
||||
## An internal flag to track whether a request is complete.
|
||||
finished: bool &default=F;
|
||||
};
|
||||
|
||||
## A token request that serves as a null/nonexistant request.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue