Expand requests support in the controller

Request records for configuration updates now store the full configuration. The
ClusterController::Request module now provies a to_string() function for
rendering requests to a string.
This commit is contained in:
Christian Kreibich 2021-11-09 21:53:33 -08:00
parent aceb05099a
commit 484f79f599

View file

@ -13,6 +13,7 @@ export {
# State specific to the set_configuration request/response events
type SetConfigurationState: record {
config: ClusterController::Types::Configuration;
requests: vector of Request &default=vector();
};
@ -44,6 +45,7 @@ export {
global finish: function(reqid: string): bool;
global is_null: function(request: Request): bool;
global to_string: function(request: Request): string;
}
# XXX this needs a mechanism for expiring stale requests
@ -84,3 +86,28 @@ function is_null(request: Request): bool
return F;
}
function to_string(request: Request): string
{
local results: string_vec;
local res: ClusterController::Types::Result;
local parent_id = "";
if ( request?$parent_id )
parent_id = fmt(" (via %s)", request$parent_id);
for ( idx in request$results )
{
res = request$results[idx];
if ( res$success )
results[|results|] = "success";
else if ( |res$error| > 0 )
results[|results|] = fmt("error (%s)", res$error);
else
results[|results|] = "error";
}
return fmt("[request %s%s %s, results: %s]", request$id, parent_id,
request$finished ? "finished" : "pending",
join_string_vec(results, ","));
}