mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +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
|
@ -13,6 +13,15 @@
|
|||
|
||||
module ClusterAgent::Runtime;
|
||||
|
||||
# Request state specific to supervisor interactions
|
||||
type SupervisorState: record {
|
||||
node: string;
|
||||
};
|
||||
|
||||
redef record ClusterController::Request::Request += {
|
||||
supervisor_state: SupervisorState &optional;
|
||||
};
|
||||
|
||||
redef ClusterController::role = ClusterController::Types::AGENT;
|
||||
|
||||
# The global configuration as passed to us by the controller
|
||||
|
@ -69,7 +78,7 @@ event SupervisorControl::destroy_response(reqid: string, result: bool)
|
|||
function supervisor_create(nc: Supervisor::NodeConfig)
|
||||
{
|
||||
local req = ClusterController::Request::create();
|
||||
req$supervisor_state = ClusterController::Request::SupervisorState($node = nc$name);
|
||||
req$supervisor_state = SupervisorState($node = nc$name);
|
||||
event SupervisorControl::create_request(req$id, nc);
|
||||
ClusterController::Log::info(fmt("issued supervisor create for %s, %s", nc$name, req$id));
|
||||
}
|
||||
|
@ -77,7 +86,7 @@ function supervisor_create(nc: Supervisor::NodeConfig)
|
|||
function supervisor_destroy(node: string)
|
||||
{
|
||||
local req = ClusterController::Request::create();
|
||||
req$supervisor_state = ClusterController::Request::SupervisorState($node = node);
|
||||
req$supervisor_state = SupervisorState($node = node);
|
||||
event SupervisorControl::destroy_request(req$id, node);
|
||||
ClusterController::Log::info(fmt("issued supervisor destroy for %s, %s", node, req$id));
|
||||
}
|
||||
|
|
|
@ -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