refactor event system
This commit is contained in:
@ -27,23 +27,16 @@
|
||||
|
||||
namespace repertory {
|
||||
// clang-format off
|
||||
E_SIMPLE1(item_timeout, trace,
|
||||
std::string, api_path, ap, E_FROM_STRING
|
||||
//WINFSP
|
||||
E_SIMPLE3(remote_winfsp_client_event, debug,
|
||||
std::string, function, func, E_FROM_STRING,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
packet::error_type, result, res, E_FROM_INT32
|
||||
);
|
||||
|
||||
E_SIMPLE2(invalid_cache_size, warn,
|
||||
std::uint64_t, cache_size, sz, E_FROM_UINT64,
|
||||
std::uint64_t, by, by, E_FROM_UINT64
|
||||
);
|
||||
|
||||
E_SIMPLE2(max_cache_size_reached, warn,
|
||||
std::uint64_t, cache_size, sz, E_FROM_UINT64,
|
||||
std::uint64_t, max_cache_size, max, E_FROM_UINT64
|
||||
);
|
||||
|
||||
E_SIMPLE2(packet_client_timeout, error,
|
||||
std::string, event_name, en, E_FROM_STRING,
|
||||
std::string, message, msg, E_FROM_STRING
|
||||
E_SIMPLE3(remote_winfsp_server_event, debug,
|
||||
std::string, function, FUNC, E_FROM_STRING,
|
||||
std::string, api_path, AP, E_FROM_STRING,
|
||||
packet::error_type, result, RES, E_FROM_INT32
|
||||
);
|
||||
|
||||
//FUSE
|
||||
@ -62,24 +55,6 @@ E_SIMPLE3(remote_fuse_server_event, debug,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
packet::error_type, result, res, E_FROM_INT32
|
||||
);
|
||||
|
||||
//WINFSP
|
||||
E_SIMPLE3(winfsp_event, debug,
|
||||
std::string, function, func, E_FROM_STRING,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
NTSTATUS, result, res, E_FROM_INT32
|
||||
);
|
||||
E_SIMPLE(drive_stop_timed_out, info);
|
||||
E_SIMPLE3(remote_winfsp_client_event, debug,
|
||||
std::string, function, func, E_FROM_STRING,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
packet::error_type, result, res, E_FROM_INT32
|
||||
);
|
||||
E_SIMPLE3(remote_winfsp_server_event, debug,
|
||||
std::string, function, FUNC, E_FROM_STRING,
|
||||
std::string, api_path, AP, E_FROM_STRING,
|
||||
packet::error_type, result, RES, E_FROM_INT32
|
||||
);
|
||||
// clang-format on
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -33,6 +33,7 @@ struct curl_error final : public i_event {
|
||||
function_name(std::string{function_name_}),
|
||||
url(std::move(url_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"curl_error"};
|
||||
|
||||
CURLcode code{};
|
||||
@ -40,7 +41,7 @@ struct curl_error final : public i_event {
|
||||
std::string url;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -31,13 +31,14 @@ struct debug_log final : public i_event {
|
||||
debug_log(std::string_view function_name_, std::string msg_)
|
||||
: function_name(std::string(function_name_)), msg(std::move(msg_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"debug_log"};
|
||||
|
||||
std::string function_name;
|
||||
std::string msg;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct directory_remove_failed final : public i_event {
|
||||
error(error_),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"directory_remove_failed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct directory_remove_failed final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct directory_removed final : public i_event {
|
||||
: api_path(std::move(api_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"directory_removed"};
|
||||
|
||||
std::string api_path;
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct directory_removed_externally final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"directory_removed_externally"};
|
||||
|
||||
std::string api_path;
|
||||
@ -42,7 +43,7 @@ struct directory_removed_externally final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::warn;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct download_begin final : public i_event {
|
||||
dest_path(std::move(dest_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"download_begin"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct download_begin final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct download_end final : public i_event {
|
||||
error(error_),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"download_end"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct download_end final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct download_progress final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
progress(progress_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"download_progress"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct download_progress final : public i_event {
|
||||
double progress{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct download_restore_failed final : public i_event {
|
||||
error(std::move(error_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"download_restore_failed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct download_restore_failed final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct download_restored final : public i_event {
|
||||
dest_path(std::move(dest_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"download_restored"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct download_restored final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -36,6 +36,7 @@ struct download_resume_add_failed final : public i_event {
|
||||
error(std::move(error_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"download_resume_add_failed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -44,7 +45,7 @@ struct download_resume_add_failed final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct download_resume_added final : public i_event {
|
||||
dest_path(std::move(dest_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"download_resume_added"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct download_resume_added final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct download_resume_removed final : public i_event {
|
||||
dest_path(std::move(dest_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"download_resume_removed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct download_resume_removed final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct download_type_selected final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
type(type_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"download_type_selected"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct download_type_selected final : public i_event {
|
||||
download_type type{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct drive_mount_failed final : public i_event {
|
||||
mount_location(std::move(mount_location_)),
|
||||
status(status_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"drive_mount_failed"};
|
||||
|
||||
std::string function_name;
|
||||
@ -42,7 +43,7 @@ struct drive_mount_failed final : public i_event {
|
||||
NTSTATUS status{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct drive_mount_result final : public i_event {
|
||||
mount_location(std::move(mount_location_)),
|
||||
result(std::move(result_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"drive_mount_result"};
|
||||
|
||||
std::string function_name;
|
||||
@ -41,7 +42,7 @@ struct drive_mount_result final : public i_event {
|
||||
std::string result;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct drive_mounted final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
mount_location(std::move(mount_location_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"drive_mounted"};
|
||||
|
||||
std::string function_name;
|
||||
std::string mount_location;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_
|
||||
|
||||
#include "events/i_event.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
struct drive_stop_timed_out final : public i_event {
|
||||
drive_stop_timed_out() = default;
|
||||
drive_stop_timed_out(std::string_view function_name_)
|
||||
: function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"drive_stop_timed_out"};
|
||||
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}", name, function_name);
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::drive_stop_timed_out> {
|
||||
static void to_json(json &data,
|
||||
const repertory::drive_stop_timed_out &value) {
|
||||
data["function_name"] = value.function_name;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::drive_stop_timed_out &value) {
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_
|
@ -33,13 +33,14 @@ struct drive_unmount_pending final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
mount_location(std::move(mount_location_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"drive_unmount_pending"};
|
||||
|
||||
std::string function_name;
|
||||
std::string mount_location;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct drive_unmounted final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
mount_location(std::move(mount_location_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"drive_unmounted"};
|
||||
|
||||
std::string function_name;
|
||||
std::string mount_location;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -28,16 +28,17 @@
|
||||
namespace repertory {
|
||||
struct event_level_changed final : public i_event {
|
||||
event_level_changed() = default;
|
||||
event_level_changed(std::string_view function_name_, event_level level_)
|
||||
: function_name(std::string(function_name_)), level(level_) {}
|
||||
event_level_changed(std::string_view function_name_, event_level new_level_)
|
||||
: function_name(std::string(function_name_)), new_level(new_level_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"event_level_changed"};
|
||||
|
||||
std::string function_name;
|
||||
event_level level{};
|
||||
event_level new_level{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
@ -46,7 +47,7 @@ struct event_level_changed final : public i_event {
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}|level|{}", name, function_name,
|
||||
event_level_to_string(level));
|
||||
event_level_to_string(new_level));
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
@ -54,14 +55,14 @@ struct event_level_changed final : public i_event {
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::event_level_changed> {
|
||||
static void to_json(json &data, const repertory::event_level_changed &value) {
|
||||
data["event_level"] = repertory::event_level_to_string(value.level);
|
||||
data["new_level"] = repertory::event_level_to_string(value.new_level);
|
||||
data["function_name"] = value.function_name;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::event_level_changed &value) {
|
||||
value.level = repertory::event_level_from_string(
|
||||
data.at("event_level").get<std::string>());
|
||||
value.new_level = repertory::event_level_from_string(
|
||||
data.at("new_level").get<std::string>());
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
}
|
||||
};
|
||||
|
@ -32,13 +32,14 @@ struct file_pinned final : public i_event {
|
||||
: api_path(std::move(api_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"file_pinned"};
|
||||
|
||||
std::string api_path;
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct file_remove_failed final : public i_event {
|
||||
error(error_),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"file_remove_failed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct file_remove_failed final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct file_removed final : public i_event {
|
||||
: api_path(std::move(api_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"file_removed"};
|
||||
|
||||
std::string api_path;
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct file_removed_externally final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"file_removed_externally"};
|
||||
|
||||
std::string api_path;
|
||||
@ -42,7 +43,7 @@ struct file_removed_externally final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::warn;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct file_unpinned final : public i_event {
|
||||
: api_path(std::move(api_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"file_unpinned"};
|
||||
|
||||
std::string api_path;
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -37,6 +37,7 @@ struct file_upload_completed final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"file_upload_completed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -46,7 +47,7 @@ struct file_upload_completed final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct file_upload_failed final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"file_upload_failed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct file_upload_failed final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::warn;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct file_upload_not_found final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"file_upload_not_found"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct file_upload_not_found final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::warn;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct file_upload_queued final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"file_upload_queued"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct file_upload_queued final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct file_upload_removed final : public i_event {
|
||||
: api_path(std::move(api_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"file_upload_removed"};
|
||||
|
||||
std::string api_path;
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct file_upload_retry final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"file_upload_retry"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct file_upload_retry final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::warn;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct filesystem_item_added final : public i_event {
|
||||
directory(directory_),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"filesystem_item_added"};
|
||||
|
||||
std::string api_parent;
|
||||
@ -43,7 +44,7 @@ struct filesystem_item_added final : public i_event {
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -37,6 +37,7 @@ struct filesystem_item_closed final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::trace};
|
||||
static constexpr const std::string_view name{"filesystem_item_closed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -46,7 +47,7 @@ struct filesystem_item_closed final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::trace;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct filesystem_item_evicted final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"filesystem_item_evicted"};
|
||||
|
||||
std::string api_path;
|
||||
@ -42,7 +43,7 @@ struct filesystem_item_evicted final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -39,6 +39,7 @@ struct filesystem_item_handle_closed final : public i_event {
|
||||
handle(handle_),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::trace};
|
||||
static constexpr const std::string_view name{"filesystem_item_handle_closed"};
|
||||
|
||||
std::string api_path;
|
||||
@ -49,7 +50,7 @@ struct filesystem_item_handle_closed final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::trace;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -37,6 +37,7 @@ struct filesystem_item_handle_opened final : public i_event {
|
||||
handle(handle_),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::trace};
|
||||
static constexpr const std::string_view name{"filesystem_item_handle_opened"};
|
||||
|
||||
std::string api_path;
|
||||
@ -46,7 +47,7 @@ struct filesystem_item_handle_opened final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::trace;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -36,6 +36,7 @@ struct filesystem_item_opened final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::trace};
|
||||
static constexpr const std::string_view name{"filesystem_item_opened"};
|
||||
|
||||
std::string api_path;
|
||||
@ -44,7 +45,7 @@ struct filesystem_item_opened final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::trace;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_INVALID_CACHE_SIZE_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_TYPES_INVALID_CACHE_SIZE_HPP_
|
||||
|
||||
#include "events/i_event.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
struct invalid_cache_size final : public i_event {
|
||||
invalid_cache_size() = default;
|
||||
invalid_cache_size(std::uint64_t cache_size_, std::string_view function_name_,
|
||||
std::uint64_t invalid_size_)
|
||||
: cache_size(cache_size_),
|
||||
function_name(std::string{function_name_}),
|
||||
invalid_size(invalid_size_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"invalid_cache_size"};
|
||||
|
||||
std::uint64_t cache_size{};
|
||||
std::string function_name;
|
||||
std::uint64_t invalid_size{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}|size|{}|by|{}", name, function_name,
|
||||
cache_size, invalid_size);
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::invalid_cache_size> {
|
||||
static void to_json(json &data, const repertory::invalid_cache_size &value) {
|
||||
data["cache_size"] = value.cache_size;
|
||||
data["function_name"] = value.function_name;
|
||||
data["invalid_size"] = value.invalid_size;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::invalid_cache_size &value) {
|
||||
data.at("cache_size").get_to<std::uint64_t>(value.cache_size);
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
data.at("invalid_size").get_to<std::uint64_t>(value.invalid_size);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_INVALID_CACHE_SIZE_HPP_
|
69
repertory/librepertory/include/events/types/item_timeout.hpp
Normal file
69
repertory/librepertory/include/events/types/item_timeout.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_ITEM_TIMEOUT_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_TYPES_ITEM_TIMEOUT_HPP_
|
||||
|
||||
#include "events/i_event.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
struct item_timeout final : public i_event {
|
||||
item_timeout() = default;
|
||||
item_timeout(std::string api_path_, std::string_view function_name_)
|
||||
: api_path(std::move(api_path_)),
|
||||
function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::trace};
|
||||
static constexpr const std::string_view name{"item_timeout"};
|
||||
|
||||
std::string api_path;
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path);
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::item_timeout> {
|
||||
static void to_json(json &data, const repertory::item_timeout &value) {
|
||||
data["api_path"] = value.api_path;
|
||||
data["function_name"] = value.function_name;
|
||||
}
|
||||
|
||||
static void from_json(const json &data, repertory::item_timeout &value) {
|
||||
data.at("api_path").get_to<std::string>(value.api_path);
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ITEM_TIMEOUT_HPP_
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_MAX_CACHE_SIZE_REACHED_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_TYPES_MAX_CACHE_SIZE_REACHED_HPP_
|
||||
|
||||
#include "events/i_event.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
struct max_cache_size_reached final : public i_event {
|
||||
max_cache_size_reached() = default;
|
||||
max_cache_size_reached(std::uint64_t cache_size_,
|
||||
std::string_view function_name_,
|
||||
std::uint64_t max_cache_size_)
|
||||
: cache_size(cache_size_),
|
||||
function_name(std::string{function_name_}),
|
||||
max_cache_size(max_cache_size_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"max_cache_size_reached"};
|
||||
|
||||
std::uint64_t cache_size{};
|
||||
std::string function_name;
|
||||
std::uint64_t max_cache_size{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}|size|{}|max|{}", name, function_name,
|
||||
cache_size, max_cache_size);
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::max_cache_size_reached> {
|
||||
static void to_json(json &data,
|
||||
const repertory::max_cache_size_reached &value) {
|
||||
data["cache_size"] = value.cache_size;
|
||||
data["function_name"] = value.function_name;
|
||||
data["max_cache_size"] = value.max_cache_size;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::max_cache_size_reached &value) {
|
||||
data.at("cache_size").get_to<std::uint64_t>(value.cache_size);
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
data.at("max_cache_size").get_to<std::uint64_t>(value.max_cache_size);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_MAX_CACHE_SIZE_REACHED_HPP_
|
@ -33,13 +33,14 @@ struct orphaned_file_detected final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"orphaned_file_detected"};
|
||||
|
||||
std::string function_name;
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -36,8 +36,10 @@ struct orphaned_file_processing_failed final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{
|
||||
"orphaned_file_processing_failed"};
|
||||
"orphaned_file_processing_failed",
|
||||
};
|
||||
|
||||
std::string dest_path;
|
||||
std::string error;
|
||||
@ -45,7 +47,7 @@ struct orphaned_file_processing_failed final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -33,13 +33,14 @@ struct orphaned_source_file_detected final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"orphaned_source_file_detected"};
|
||||
|
||||
std::string function_name;
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -33,13 +33,14 @@ struct orphaned_source_file_removed final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"orphaned_source_file_removed"};
|
||||
|
||||
std::string function_name;
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_PACKET_CLIENT_TIMEOUT_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_TYPES_PACKET_CLIENT_TIMEOUT_HPP_
|
||||
|
||||
#include "events/i_event.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
struct packet_client_timeout final : public i_event {
|
||||
packet_client_timeout() = default;
|
||||
packet_client_timeout(std::string event_name_,
|
||||
std::string_view function_name_, std::string msg_)
|
||||
: event_name(std::move(event_name_)),
|
||||
function_name(std::string(function_name_)),
|
||||
msg(std::move(msg_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"packet_client_timeout"};
|
||||
|
||||
std::string event_name;
|
||||
std::string function_name;
|
||||
std::string msg;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}|event|{}|msg|{}", name, function_name,
|
||||
event_name, msg);
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::packet_client_timeout> {
|
||||
static void to_json(json &data,
|
||||
const repertory::packet_client_timeout &value) {
|
||||
data["event_name"] = value.event_name;
|
||||
data["function_name"] = value.function_name;
|
||||
data["msg"] = value.msg;
|
||||
}
|
||||
|
||||
static void from_json(const json &data,
|
||||
repertory::packet_client_timeout &value) {
|
||||
data.at("event_name").get_to<std::string>(value.event_name);
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
data.at("msg").get_to<std::string>(value.msg);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PACKET_CLIENT_TIMEOUT_HPP_
|
@ -32,13 +32,14 @@ struct polling_item_begin final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
item_name(std::move(item_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"polling_item_begin"};
|
||||
|
||||
std::string function_name;
|
||||
std::string item_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct polling_item_end final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
item_name(std::move(item_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"polling_item_end"};
|
||||
|
||||
std::string function_name;
|
||||
std::string item_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct provider_offline final : public i_event {
|
||||
host_name_or_ip(std::move(host_name_or_ip_)),
|
||||
port(port_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::warn};
|
||||
static constexpr const std::string_view name{"provider_offline"};
|
||||
|
||||
std::string function_name;
|
||||
@ -41,7 +42,7 @@ struct provider_offline final : public i_event {
|
||||
std::uint16_t port{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -34,6 +34,7 @@ struct provider_upload_begin final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"provider_upload_begin"};
|
||||
|
||||
std::string api_path;
|
||||
@ -41,7 +42,7 @@ struct provider_upload_begin final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::warn;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct provider_upload_end final : public i_event {
|
||||
function_name(std::string(function_name_)),
|
||||
source_path(std::move(source_path_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"provider_upload_end"};
|
||||
|
||||
std::string api_path;
|
||||
@ -43,7 +44,7 @@ struct provider_upload_end final : public i_event {
|
||||
std::string source_path;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -31,13 +31,14 @@ struct repertory_exception final : public i_event {
|
||||
repertory_exception(std::string_view function_name_, std::string msg_)
|
||||
: function_name(std::string(function_name_)), msg(std::move(msg_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::error};
|
||||
static constexpr const std::string_view name{"repertory_exception"};
|
||||
|
||||
std::string function_name;
|
||||
std::string msg;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::error;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -33,13 +33,14 @@ struct service_start_begin final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
service_name(std::move(service_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"service_start_begin"};
|
||||
|
||||
std::string function_name;
|
||||
std::string service_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct service_start_end final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
service_name(std::move(service_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"service_start_end"};
|
||||
|
||||
std::string function_name;
|
||||
std::string service_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct service_stop_begin final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
service_name(std::move(service_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"service_stop_begin"};
|
||||
|
||||
std::string function_name;
|
||||
std::string service_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -32,13 +32,14 @@ struct service_stop_end final : public i_event {
|
||||
: function_name(std::string(function_name_)),
|
||||
service_name(std::move(service_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"service_stop_end"};
|
||||
|
||||
std::string function_name;
|
||||
std::string service_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::debug;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -31,12 +31,13 @@ struct unmount_requested final : public i_event {
|
||||
unmount_requested(std::string_view function_name_)
|
||||
: function_name(std::string(function_name_)) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"unmount_requested"};
|
||||
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
@ -35,6 +35,7 @@ struct unmount_result final : public i_event {
|
||||
mount_location(std::move(mount_location_)),
|
||||
result(result_) {}
|
||||
|
||||
static constexpr const event_level level{event_level::info};
|
||||
static constexpr const std::string_view name{"unmount_result"};
|
||||
|
||||
std::string function_name;
|
||||
@ -42,7 +43,7 @@ struct unmount_result final : public i_event {
|
||||
std::int32_t result{};
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return event_level::info;
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
|
77
repertory/librepertory/include/events/types/winfsp_event.hpp
Normal file
77
repertory/librepertory/include/events/types/winfsp_event.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_WINFSP_EVENT_HPP_
|
||||
#define REPERTORY_INCLUDE_EVENTS_TYPES_WINFSP_EVENT_HPP_
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "events/i_event.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory {
|
||||
struct winfsp_event final : public i_event {
|
||||
winfsp_event() = default;
|
||||
winfsp_event(std::string api_path_, NTSTATUS error_,
|
||||
std::string_view function_name_)
|
||||
: api_path(std::move(api_path_)),
|
||||
error(error_),
|
||||
function_name(std::string{function_name_}) {}
|
||||
|
||||
static constexpr const event_level level{event_level::debug};
|
||||
static constexpr const std::string_view name{"winfsp_event"};
|
||||
|
||||
std::string api_path;
|
||||
NTSTATUS error{};
|
||||
std::string function_name;
|
||||
|
||||
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||
return level;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||
return fmt::format("{}|func|{}|ap|{}|error|{}", name, function_name,
|
||||
api_path, error);
|
||||
}
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<repertory::winfsp_event> {
|
||||
static void to_json(json &data, const repertory::winfsp_event &value) {
|
||||
data["api_path"] = value.api_path;
|
||||
data["error"] = value.error;
|
||||
data["function_name"] = value.function_name;
|
||||
}
|
||||
|
||||
static void from_json(const json &data, repertory::winfsp_event &value) {
|
||||
data.at("api_path").get_to<std::string>(value.api_path);
|
||||
data.at("error").get_to<NTSTATUS>(value.error);
|
||||
data.at("function_name").get_to<std::string>(value.function_name);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // defined(_WIN32)
|
||||
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_WINFSP_EVENT_HPP_
|
@ -22,6 +22,7 @@
|
||||
#include "comm/packet/packet_client.hpp"
|
||||
|
||||
#include "events/event_system.hpp"
|
||||
#include "events/types/packet_client_timeout.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/collection.hpp"
|
||||
@ -105,8 +106,8 @@ void packet_client::put_client(std::shared_ptr<client> &cli) {
|
||||
}
|
||||
}
|
||||
|
||||
auto packet_client::read_packet(client &cli,
|
||||
packet &response) const -> packet::error_type {
|
||||
auto packet_client::read_packet(client &cli, packet &response) const
|
||||
-> packet::error_type {
|
||||
data_buffer buffer(sizeof(std::uint32_t));
|
||||
const auto read_buffer = [&]() {
|
||||
std::uint32_t offset{};
|
||||
@ -147,8 +148,8 @@ void packet_client::resolve() {
|
||||
.resolve(cfg_.host_name_or_ip, std::to_string(cfg_.api_port));
|
||||
}
|
||||
|
||||
auto packet_client::send(std::string_view method,
|
||||
std::uint32_t &service_flags) -> packet::error_type {
|
||||
auto packet_client::send(std::string_view method, std::uint32_t &service_flags)
|
||||
-> packet::error_type {
|
||||
packet request;
|
||||
return send(method, request, service_flags);
|
||||
}
|
||||
@ -160,8 +161,8 @@ auto packet_client::send(std::string_view method, packet &request,
|
||||
}
|
||||
|
||||
auto packet_client::send(std::string_view method, packet &request,
|
||||
packet &response,
|
||||
std::uint32_t &service_flags) -> packet::error_type {
|
||||
packet &response, std::uint32_t &service_flags)
|
||||
-> packet::error_type {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto success = false;
|
||||
@ -184,7 +185,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
||||
timeout request_timeout(
|
||||
[method, current_client]() {
|
||||
event_system::instance().raise<packet_client_timeout>(
|
||||
"request", std::string{method});
|
||||
"request", function_name, std::string{method});
|
||||
packet_client::close(*current_client);
|
||||
},
|
||||
std::chrono::milliseconds(cfg_.send_timeout_ms));
|
||||
@ -206,7 +207,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
||||
timeout response_timeout(
|
||||
[method, current_client]() {
|
||||
event_system::instance().raise<packet_client_timeout>(
|
||||
"response", std::string{method});
|
||||
"response", function_name, std::string{method});
|
||||
packet_client::close(*current_client);
|
||||
},
|
||||
std::chrono::milliseconds(cfg_.recv_timeout_ms));
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "events/event_system.hpp"
|
||||
#include "events/types/drive_mount_result.hpp"
|
||||
#include "events/types/drive_mounted.hpp"
|
||||
#include "events/types/drive_stop_timed_out.hpp"
|
||||
#include "events/types/drive_unmount_pending.hpp"
|
||||
#include "events/types/drive_unmounted.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
@ -281,6 +282,7 @@ void fuse_drive::stop_all() {
|
||||
});
|
||||
|
||||
if (future.wait_for(30s) == std::future_status::timeout) {
|
||||
event_system::instance().raise<drive_stop_timed_out>(function_name);
|
||||
app_config::set_stop_requested();
|
||||
future.wait();
|
||||
}
|
||||
@ -294,7 +296,7 @@ void fuse_drive::destroy_impl(void *ptr) {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
event_system::instance().raise<drive_unmount_pending>(function_name,
|
||||
get_mount_location());
|
||||
get_mount_location());
|
||||
|
||||
stop_all();
|
||||
|
||||
@ -303,7 +305,7 @@ void fuse_drive::destroy_impl(void *ptr) {
|
||||
fuse_base::destroy_impl(ptr);
|
||||
|
||||
event_system::instance().raise<drive_unmounted>(function_name,
|
||||
get_mount_location());
|
||||
get_mount_location());
|
||||
}
|
||||
|
||||
auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode,
|
||||
@ -617,7 +619,7 @@ void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
|
||||
}
|
||||
|
||||
event_system::instance().raise<drive_mounted>(function_name,
|
||||
get_mount_location());
|
||||
get_mount_location());
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::raise_error(function_name, e, "exception during fuse init");
|
||||
|
||||
|
@ -31,9 +31,11 @@
|
||||
#include "events/types/drive_mount_failed.hpp"
|
||||
#include "events/types/drive_mount_result.hpp"
|
||||
#include "events/types/drive_mounted.hpp"
|
||||
#include "events/types/drive_stop_timed_out.hpp"
|
||||
#include "events/types/drive_unmount_pending.hpp"
|
||||
#include "events/types/drive_unmounted.hpp"
|
||||
#include "events/types/unmount_requested.hpp"
|
||||
#include "events/types/winfsp_event.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "providers/i_provider.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -52,9 +54,9 @@ namespace repertory {
|
||||
#define RAISE_WINFSP_EVENT(func, file, ret) \
|
||||
if (config_.get_enable_drive_events() && \
|
||||
(((config_.get_event_level() >= winfsp_event::level) && \
|
||||
(ret != STATUS_SUCCESS)) || \
|
||||
((ret) != STATUS_SUCCESS)) || \
|
||||
(config_.get_event_level() >= event_level::trace))) \
|
||||
event_system::instance().raise<winfsp_event>(std::string{func}, file, ret)
|
||||
event_system::instance().raise<winfsp_event>(file, func, ret)
|
||||
|
||||
winfsp_drive::winfsp_service::winfsp_service(
|
||||
lock_data &lock, winfsp_drive &drive, std::vector<std::string> drive_args,
|
||||
@ -88,8 +90,8 @@ auto winfsp_drive::handle_error(std::string_view function_name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/,
|
||||
PWSTR * /*Argv*/) -> NTSTATUS {
|
||||
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto mount_location = utils::string::to_lower(
|
||||
@ -136,7 +138,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
||||
|
||||
timeout stop_timeout(
|
||||
[]() {
|
||||
event_system::instance().raise<drive_stop_timed_out>();
|
||||
event_system::instance().raise<drive_stop_timed_out>(function_name);
|
||||
app_config::set_stop_requested();
|
||||
},
|
||||
30s);
|
||||
@ -468,9 +470,10 @@ auto winfsp_drive::get_item_meta(const std::string &api_path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto winfsp_drive::get_security_by_name(
|
||||
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size) -> NTSTATUS {
|
||||
auto winfsp_drive::get_security_by_name(PWSTR file_name, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size)
|
||||
-> NTSTATUS {
|
||||
auto api_path =
|
||||
utils::path::create_api_path(utils::string::to_utf8(file_name));
|
||||
|
||||
@ -730,8 +733,8 @@ auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT32 attributes, BOOLEAN replace_attributes,
|
||||
UINT64 /*allocation_size*/,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
UINT64 /*allocation_size*/, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
@ -837,8 +840,8 @@ void winfsp_drive::populate_file_info(std::uint64_t file_size,
|
||||
}
|
||||
|
||||
auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
|
||||
UINT64 offset, ULONG length,
|
||||
PULONG bytes_transferred) -> NTSTATUS {
|
||||
UINT64 offset, ULONG length, PULONG bytes_transferred)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
*bytes_transferred = 0U;
|
||||
@ -893,8 +896,8 @@ auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
|
||||
|
||||
auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
PWSTR /*pattern*/, PWSTR marker, PVOID buffer,
|
||||
ULONG buffer_length,
|
||||
PULONG bytes_transferred) -> NTSTATUS {
|
||||
ULONG buffer_length, PULONG bytes_transferred)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
@ -1050,8 +1053,8 @@ auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/,
|
||||
auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||
UINT32 attributes, UINT64 creation_time,
|
||||
UINT64 last_access_time, UINT64 last_write_time,
|
||||
UINT64 change_time,
|
||||
FileInfo *file_info) -> NTSTATUS {
|
||||
UINT64 change_time, FileInfo *file_info)
|
||||
-> NTSTATUS {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::string api_path;
|
||||
@ -1195,6 +1198,7 @@ void winfsp_drive::stop_all() {
|
||||
});
|
||||
|
||||
if (future.wait_for(30s) == std::future_status::timeout) {
|
||||
event_system::instance().raise<drive_stop_timed_out>(function_name);
|
||||
app_config::set_stop_requested();
|
||||
future.wait();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ console_consumer::console_consumer(event_level level) {
|
||||
|
||||
E_SUBSCRIBE_ALL(process_event2);
|
||||
E_SUBSCRIBE_EXACT(event_level_changed,
|
||||
[](auto &&event) { set_level(event.level); });
|
||||
[](auto &&event) { set_level(event.new_level); });
|
||||
}
|
||||
|
||||
console_consumer::~console_consumer() { E_CONSUMER_RELEASE(); }
|
||||
|
@ -68,7 +68,7 @@ logging_consumer::logging_consumer(event_level level,
|
||||
|
||||
E_SUBSCRIBE_ALL(process_event2);
|
||||
E_SUBSCRIBE_EXACT(event_level_changed,
|
||||
[](auto &&event) { set_level(event.level); });
|
||||
[](auto &&event) { set_level(event.new_level); });
|
||||
}
|
||||
|
||||
logging_consumer::~logging_consumer() { E_CONSUMER_RELEASE(); }
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
#include "events/types/invalid_cache_size.hpp"
|
||||
#include "events/types/max_cache_size_reached.hpp"
|
||||
#include "types/startup_exception.hpp"
|
||||
#include "utils/file_utils.hpp"
|
||||
|
||||
@ -30,6 +32,8 @@ namespace repertory {
|
||||
cache_size_mgr cache_size_mgr::instance_{};
|
||||
|
||||
auto cache_size_mgr::expand(std::uint64_t size) -> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
unique_mutex_lock lock(mtx_);
|
||||
|
||||
if (cfg_ == nullptr) {
|
||||
@ -53,8 +57,8 @@ auto cache_size_mgr::expand(std::uint64_t size) -> api_error {
|
||||
while (not get_stop_requested() && cache_size_ > max_cache_size &&
|
||||
cache_dir.count() > 1U) {
|
||||
if (last_cache_size != cache_size_) {
|
||||
event_system::instance().raise<max_cache_size_reached>(cache_size_,
|
||||
max_cache_size);
|
||||
event_system::instance().raise<max_cache_size_reached>(
|
||||
cache_size_, function_name, max_cache_size);
|
||||
last_cache_size = cache_size_;
|
||||
}
|
||||
notify_.wait_for(lock, cache_wait_secs);
|
||||
@ -93,6 +97,8 @@ void cache_size_mgr::initialize(app_config *cfg) {
|
||||
}
|
||||
|
||||
auto cache_size_mgr::shrink(std::uint64_t size) -> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
mutex_lock lock(mtx_);
|
||||
if (size == 0U) {
|
||||
notify_.notify_all();
|
||||
@ -102,7 +108,8 @@ auto cache_size_mgr::shrink(std::uint64_t size) -> api_error {
|
||||
if (cache_size_ >= size) {
|
||||
cache_size_ -= size;
|
||||
} else {
|
||||
event_system::instance().raise<invalid_cache_size>(cache_size_, size);
|
||||
event_system::instance().raise<invalid_cache_size>(cache_size_,
|
||||
function_name, size);
|
||||
cache_size_ = 0U;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "events/types/file_upload_removed.hpp"
|
||||
#include "events/types/file_upload_retry.hpp"
|
||||
#include "events/types/filesystem_item_evicted.hpp"
|
||||
#include "events/types/item_timeout.hpp"
|
||||
#include "events/types/service_start_begin.hpp"
|
||||
#include "events/types/service_start_end.hpp"
|
||||
#include "events/types/service_stop_begin.hpp"
|
||||
@ -106,6 +107,8 @@ auto file_manager::close_all(const std::string &api_path) -> bool {
|
||||
}
|
||||
|
||||
void file_manager::close_timed_out_files() {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
unique_recur_mutex_lock file_lock(open_file_mtx_);
|
||||
auto closeable_list =
|
||||
std::accumulate(open_file_lookup_.begin(), open_file_lookup_.end(),
|
||||
@ -124,8 +127,8 @@ void file_manager::close_timed_out_files() {
|
||||
|
||||
for (auto &closeable_file : closeable_list) {
|
||||
closeable_file->close();
|
||||
event_system::instance().raise<item_timeout>(
|
||||
closeable_file->get_api_path());
|
||||
event_system::instance().raise<item_timeout>(closeable_file->get_api_path(),
|
||||
function_name);
|
||||
}
|
||||
closeable_list.clear();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "events/types/filesystem_item_handle_closed.hpp"
|
||||
#include "events/types/filesystem_item_handle_opened.hpp"
|
||||
#include "events/types/filesystem_item_opened.hpp"
|
||||
#include "events/types/item_timeout.hpp"
|
||||
#include "events/types/service_start_begin.hpp"
|
||||
#include "events/types/service_start_end.hpp"
|
||||
#include "events/types/service_stop_begin.hpp"
|
||||
@ -132,7 +133,7 @@ TEST_F(file_manager_test, can_create_and_close_file) {
|
||||
mgr.start();
|
||||
|
||||
event_capture capture({
|
||||
"item_timeout",
|
||||
item_timeout::name,
|
||||
filesystem_item_opened::name,
|
||||
filesystem_item_handle_opened::name,
|
||||
filesystem_item_handle_closed::name,
|
||||
@ -241,7 +242,7 @@ TEST_F(file_manager_test, can_open_and_close_file) {
|
||||
mgr.start();
|
||||
|
||||
event_capture capture({
|
||||
"item_timeout",
|
||||
item_timeout::name,
|
||||
filesystem_item_opened::name,
|
||||
filesystem_item_handle_opened::name,
|
||||
filesystem_item_handle_closed::name,
|
||||
@ -647,7 +648,7 @@ TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) {
|
||||
}
|
||||
|
||||
event_capture capture({
|
||||
"item_timeout",
|
||||
item_timeout::name,
|
||||
file_upload_queued::name,
|
||||
file_upload_completed::name,
|
||||
});
|
||||
@ -1463,7 +1464,7 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) {
|
||||
auto source_path = utils::path::combine(cfg->get_cache_directory(),
|
||||
{utils::create_uuid_string()});
|
||||
|
||||
event_consumer consumer("item_timeout", [](const i_event &evt) {
|
||||
event_consumer consumer(item_timeout::name, [](const i_event &evt) {
|
||||
const auto &evt2 = dynamic_cast<const item_timeout &>(evt);
|
||||
EXPECT_STREQ("/test_download_timeout.txt",
|
||||
evt2.get_api_path().get<std::string>().c_str());
|
||||
@ -1489,7 +1490,7 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) {
|
||||
return api_error::success;
|
||||
});
|
||||
|
||||
event_capture capture({"item_timeout"});
|
||||
event_capture capture({item_timeout::name});
|
||||
|
||||
EXPECT_CALL(mp, read_file_bytes)
|
||||
.WillRepeatedly([](const std::string & /* api_path */, std::size_t size,
|
||||
@ -1590,7 +1591,7 @@ TEST_F(file_manager_test,
|
||||
mgr.start();
|
||||
|
||||
event_capture capture({
|
||||
"item_timeout",
|
||||
item_timeout::name,
|
||||
filesystem_item_opened::name,
|
||||
filesystem_item_handle_opened::name,
|
||||
filesystem_item_handle_closed::name,
|
||||
|
Reference in New Issue
Block a user