refactor: rename DTree to DValue
This commit is contained in:
+25
-25
@@ -24,8 +24,8 @@ static void* request_fault_frames[64];
|
||||
static volatile sig_atomic_t request_fault_frame_count = 0;
|
||||
static int websocket_exec_fd = -1;
|
||||
static String websocket_exec_read_buffer = "";
|
||||
static std::deque<DTree> websocket_exec_pending_jobs;
|
||||
static DTree websocket_exec_inflight_job;
|
||||
static std::deque<DValue> websocket_exec_pending_jobs;
|
||||
static DValue websocket_exec_inflight_job;
|
||||
static String websocket_exec_write_buffer = "";
|
||||
|
||||
void close_inherited_server_sockets();
|
||||
@@ -73,7 +73,7 @@ void render_request_failure(Request& request, String title, String details, Stri
|
||||
|
||||
if(!request.resources.is_cli)
|
||||
{
|
||||
DTree error_info;
|
||||
DValue error_info;
|
||||
error_info["type"] = "runtime_error";
|
||||
error_info["title"] = title;
|
||||
error_info["details"] = details;
|
||||
@@ -223,7 +223,7 @@ void websocket_exec_fail_inflight_job(String reason = "websocket handler unavail
|
||||
websocket_exec_write_buffer = "";
|
||||
}
|
||||
|
||||
void websocket_exec_queue_job(DTree job)
|
||||
void websocket_exec_queue_job(DValue job)
|
||||
{
|
||||
if(job["connection_id"].to_string() == "")
|
||||
return;
|
||||
@@ -251,25 +251,25 @@ StringList websocket_exec_snapshot_connections(String scope)
|
||||
return(server.websocket_connection_ids(scope));
|
||||
}
|
||||
|
||||
void websocket_exec_append_command(DTree command)
|
||||
void websocket_exec_append_command(DValue command)
|
||||
{
|
||||
if(!context)
|
||||
return;
|
||||
context->resources.websocket_dispatch_commands.push(command);
|
||||
}
|
||||
|
||||
DTree websocket_exec_make_message_command(String action, String message, bool binary)
|
||||
DValue websocket_exec_make_message_command(String action, String message, bool binary)
|
||||
{
|
||||
DTree command;
|
||||
DValue command;
|
||||
command["action"] = action;
|
||||
command["binary"].set_bool(binary);
|
||||
command["message_b64"] = base64_encode(message);
|
||||
return(command);
|
||||
}
|
||||
|
||||
DTree websocket_exec_make_close_command(String connection_id, u16 status_code = 1000, String reason = "")
|
||||
DValue websocket_exec_make_close_command(String connection_id, u16 status_code = 1000, String reason = "")
|
||||
{
|
||||
DTree command;
|
||||
DValue command;
|
||||
command["action"] = "close";
|
||||
command["connection_id"] = connection_id;
|
||||
command["status_code"] = (f64)status_code;
|
||||
@@ -277,7 +277,7 @@ DTree websocket_exec_make_close_command(String connection_id, u16 status_code =
|
||||
return(command);
|
||||
}
|
||||
|
||||
void websocket_exec_apply_command(DTree command)
|
||||
void websocket_exec_apply_command(DValue command)
|
||||
{
|
||||
String action = command["action"].to_string();
|
||||
if(action == "broadcast")
|
||||
@@ -308,7 +308,7 @@ void websocket_exec_apply_command(DTree command)
|
||||
}
|
||||
}
|
||||
|
||||
void websocket_exec_apply_result(DTree result)
|
||||
void websocket_exec_apply_result(DValue result)
|
||||
{
|
||||
if(result["type"].to_string() != "result")
|
||||
return;
|
||||
@@ -326,7 +326,7 @@ void websocket_exec_apply_result(DTree result)
|
||||
if(connection)
|
||||
connection->websocket_state = result["connection_state"];
|
||||
|
||||
result["commands"].each([] (DTree command, String) {
|
||||
result["commands"].each([] (DValue command, String) {
|
||||
websocket_exec_apply_command(command);
|
||||
});
|
||||
|
||||
@@ -338,7 +338,7 @@ void websocket_exec_handle_ipc_line(String line)
|
||||
line = trim(line);
|
||||
if(line == "")
|
||||
return;
|
||||
DTree result = json_decode(line);
|
||||
DValue result = json_decode(line);
|
||||
websocket_exec_apply_result(result);
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ void websocket_exec_flush_queue()
|
||||
}
|
||||
}
|
||||
|
||||
Request websocket_exec_build_event_request(DTree job, String message)
|
||||
Request websocket_exec_build_event_request(DValue job, String message)
|
||||
{
|
||||
Request event_request;
|
||||
event_request.server = &server_state;
|
||||
@@ -425,7 +425,7 @@ Request websocket_exec_build_event_request(DTree job, String message)
|
||||
event_request.resources.websocket_is_binary = job["is_binary"].to_bool();
|
||||
event_request.resources.websocket_is_text = job["is_text"].to_bool();
|
||||
event_request.resources.websocket_dispatch_capture = true;
|
||||
job["scope_connections"].each([&] (DTree item, String) {
|
||||
job["scope_connections"].each([&] (DValue item, String) {
|
||||
event_request.resources.websocket_scope_connection_ids.push_back(item.to_string());
|
||||
});
|
||||
event_request.connection = job["connection_state"];
|
||||
@@ -451,7 +451,7 @@ Request websocket_exec_build_event_request(DTree job, String message)
|
||||
return(event_request);
|
||||
}
|
||||
|
||||
bool websocket_exec_send_response(int fd, DTree response)
|
||||
bool websocket_exec_send_response(int fd, DValue response)
|
||||
{
|
||||
String encoded = json_encode(response) + "\n";
|
||||
size_t offset = 0;
|
||||
@@ -475,7 +475,7 @@ void websocket_exec_process_job_line(int fd, String line)
|
||||
if(line == "")
|
||||
return;
|
||||
|
||||
DTree job = json_decode(line);
|
||||
DValue job = json_decode(line);
|
||||
if(job["type"].to_string() != "dispatch")
|
||||
return;
|
||||
|
||||
@@ -498,7 +498,7 @@ void websocket_exec_process_job_line(int fd, String line)
|
||||
cleanup_mysql_connections();
|
||||
cleanup_sqlite_connections();
|
||||
|
||||
DTree response;
|
||||
DValue response;
|
||||
response["type"] = "result";
|
||||
response["connection_id"] = event_request.resources.websocket_connection_id;
|
||||
response["connection_state"] = event_request.connection;
|
||||
@@ -698,7 +698,7 @@ bool ws_send(String message, bool binary, String scope)
|
||||
String normalized_scope = normalize_ws_scope(scope);
|
||||
if(context && context->resources.websocket_dispatch_capture)
|
||||
{
|
||||
DTree command = websocket_exec_make_message_command("broadcast", message, binary);
|
||||
DValue command = websocket_exec_make_message_command("broadcast", message, binary);
|
||||
command["scope"] = normalized_scope;
|
||||
websocket_exec_append_command(command);
|
||||
return(true);
|
||||
@@ -710,7 +710,7 @@ bool ws_send_to(String connection_id, String message, bool binary)
|
||||
{
|
||||
if(context && context->resources.websocket_dispatch_capture)
|
||||
{
|
||||
DTree command = websocket_exec_make_message_command("send_to", message, binary);
|
||||
DValue command = websocket_exec_make_message_command("send_to", message, binary);
|
||||
command["connection_id"] = connection_id;
|
||||
websocket_exec_append_command(command);
|
||||
return(true);
|
||||
@@ -851,7 +851,7 @@ int handle_cli_complete(FastCGIRequest& request)
|
||||
request.params["DOCUMENT_ROOT"] = document_root;
|
||||
request.params["SCRIPT_FILENAME"] = script_filename;
|
||||
prepare_request_body_maps(request);
|
||||
request.props = DTree();
|
||||
request.props = DValue();
|
||||
compiler_invoke_cli(&request, script_filename);
|
||||
}
|
||||
}
|
||||
@@ -935,7 +935,7 @@ int handle_complete(FastCGIRequest& request) {
|
||||
try
|
||||
{
|
||||
prepare_request_body_maps(request);
|
||||
request.props = DTree();
|
||||
request.props = DValue();
|
||||
if(request.resources.is_cli)
|
||||
compiler_invoke_cli(&request, request.params["SCRIPT_FILENAME"]);
|
||||
else if(request.params["UCE_SERVE_HTTP"] == "1")
|
||||
@@ -988,7 +988,7 @@ int handle_websocket_message(FastCGIRequest& request, const String& message, u8
|
||||
return(0);
|
||||
}
|
||||
|
||||
DTree job;
|
||||
DValue job;
|
||||
job["type"] = "dispatch";
|
||||
job["connection_id"] = request.resources.websocket_connection_id;
|
||||
job["scope"] = request.resources.websocket_scope;
|
||||
@@ -1004,7 +1004,7 @@ int handle_websocket_message(FastCGIRequest& request, const String& message, u8
|
||||
|
||||
for(auto& connection_id : websocket_exec_snapshot_connections(request.resources.websocket_scope))
|
||||
{
|
||||
DTree snapshot_item;
|
||||
DValue snapshot_item;
|
||||
snapshot_item = connection_id;
|
||||
job["scope_connections"].push(snapshot_item);
|
||||
}
|
||||
@@ -1069,7 +1069,7 @@ String custom_server_task_key(String key)
|
||||
|
||||
String custom_server_config_encode(String key, String type, String bind, String file_name, String function_name)
|
||||
{
|
||||
DTree config;
|
||||
DValue config;
|
||||
config["key"] = key;
|
||||
config["type"] = type;
|
||||
config["bind"] = bind;
|
||||
|
||||
Reference in New Issue
Block a user