dragonfly/addons/db/functions/fnc_processQueue.sqf
Jacob Schmidt b23679a8c3 feat(debug): Enhance logging for task management and data handling
Added conditional logging for various functions in the DragonflyDB interface to improve debugging capabilities. This includes detailed logs for task processing, fetching, publishing, and subscribing actions, which are now only active in debug mode. Additionally, updated the buffer size and path handling in the main extension code for better performance and compatibility.
2025-03-23 22:32:18 -05:00

167 lines
4.9 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: dragonfly_db_fnc_processQueue
* Author: Creedcoder, J.Schmidt
* Edit: 07.15.2024
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
*
* Do not edit without permission!
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
* PO Box 1866, Mountain View, CA 94042
*
* [Description]
* Process queue of tasks.
*
* Arguments:
* N/A
*
* Return Value:
* N/A
*
* Examples:
* [] spawn dragonfly_db_fnc_processQueue (Server or Singleplayer Only)
* [] remoteExec ["dragonfly_db_fnc_processQueue", 2, false] (Multiplayer Only)
*
* Public: Yes
*/
GVAR(isProcessing) = true;
while { count GVAR(taskQueue) > 0} do {
private _task = GVAR(taskQueue) deleteAt 0;
private _taskType = _task select 0;
private _key = _task select 1;
private _keyField = _task select 2;
private _index = _task select 3;
private _value = _task select 4;
private _function = _task select 5;
private _call = _task select 6;
private _netId = _task select 7;
#ifdef __ARMA__DEBUG__
diag_log text format ["Initializing Task: %1", _task];
#endif
switch (_taskType) do {
case "get": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(get);
};
case "set": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _value] call FUNC(set);
};
case "del": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key] call FUNC(delete);
};
case "hget": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField, _function, _call, _netId] call FUNC(hashGet);
};
case "hgetid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField, _function, _call, _netId] call FUNC(hashGetId);
};
case "hgetall": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_function, _call, _netId] call FUNC(hashGetAll);
};
case "hgetallid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(hashGetAllId);
};
case "hset": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField, _value] call FUNC(hashSet);
};
case "hsetbulk": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_value] call FUNC(hashSetBulk);
};
case "hsetid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField, _value] call FUNC(hashSetId);
};
case "hsetidbulk": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_value] call FUNC(hashSetIdBulk);
};
case "listadd": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _value] call FUNC(listAdd);
};
case "listidx": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index, _function, _call, _netId] call FUNC(listGet);
};
case "listrng": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(listLoad);
};
case "listrem": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index] call FUNC(listRemove);
};
case "listset": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index, _value] call FUNC(listSet);
};
};
sleep 1;
};
GVAR(isProcessing) = false;