refactor event system
This commit is contained in:
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
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_DRIVES_FUSE_EVENTS_HPP_
|
|
||||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
|
||||||
// clang-format off
|
|
||||||
E_SIMPLE3(fuse_event, debug,
|
|
||||||
std::string, function, func, E_FROM_STRING,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
int, result, res, E_FROM_INT32
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(fuse_args_parsed, info,
|
|
||||||
std::string, arguments, args, E_FROM_STRING
|
|
||||||
);
|
|
||||||
// clang-format on
|
|
||||||
} // namespace repertory
|
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_
|
|
@ -23,7 +23,7 @@
|
|||||||
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
#define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
@ -31,7 +31,7 @@ class app_config;
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
|
|
||||||
class fuse_base {
|
class fuse_base {
|
||||||
E_CONSUMER();
|
E_CONSUMER2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit fuse_base(app_config &config);
|
explicit fuse_base(app_config &config);
|
||||||
@ -61,7 +61,7 @@ private:
|
|||||||
static auto instance() -> fuse_base &;
|
static auto instance() -> fuse_base &;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct fuse_operations fuse_ops_ {};
|
struct fuse_operations fuse_ops_{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
@ -78,9 +78,9 @@ private:
|
|||||||
static void execute_void_callback(std::string_view function_name,
|
static void execute_void_callback(std::string_view function_name,
|
||||||
const std::function<void()> &cb);
|
const std::function<void()> &cb);
|
||||||
|
|
||||||
static auto
|
static auto execute_void_pointer_callback(std::string_view function_name,
|
||||||
execute_void_pointer_callback(std::string_view function_name,
|
const std::function<void *()> &cb)
|
||||||
const std::function<void *()> &cb) -> void *;
|
-> void *;
|
||||||
|
|
||||||
void raise_fuse_event(std::string_view function_name,
|
void raise_fuse_event(std::string_view function_name,
|
||||||
std::string_view api_path, int ret,
|
std::string_view api_path, int ret,
|
||||||
@ -104,8 +104,8 @@ private:
|
|||||||
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid,
|
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid,
|
||||||
struct fuse_file_info *fi) -> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] static auto chown_(const char *path, uid_t uid,
|
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid)
|
||||||
gid_t gid) -> int;
|
-> int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] static auto create_(const char *path, mode_t mode,
|
[[nodiscard]] static auto create_(const char *path, mode_t mode,
|
||||||
@ -114,8 +114,8 @@ private:
|
|||||||
static void destroy_(void *ptr);
|
static void destroy_(void *ptr);
|
||||||
|
|
||||||
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
|
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
|
||||||
off_t length,
|
off_t length, struct fuse_file_info *fi)
|
||||||
struct fuse_file_info *fi) -> int;
|
-> int;
|
||||||
|
|
||||||
#if FUSE_USE_VERSION < 30
|
#if FUSE_USE_VERSION < 30
|
||||||
[[nodiscard]] static auto fgetattr_(const char *path, struct stat *st,
|
[[nodiscard]] static auto fgetattr_(const char *path, struct stat *st,
|
||||||
@ -156,8 +156,8 @@ private:
|
|||||||
|
|
||||||
[[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int;
|
[[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto open_(const char *path,
|
[[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi)
|
||||||
struct fuse_file_info *fi) -> int;
|
-> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto opendir_(const char *path,
|
[[nodiscard]] static auto opendir_(const char *path,
|
||||||
struct fuse_file_info *fi) -> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
@ -174,8 +174,8 @@ private:
|
|||||||
#else
|
#else
|
||||||
[[nodiscard]] static auto readdir_(const char *path, void *buf,
|
[[nodiscard]] static auto readdir_(const char *path, void *buf,
|
||||||
fuse_fill_dir_t fuse_fill_dir,
|
fuse_fill_dir_t fuse_fill_dir,
|
||||||
off_t offset,
|
off_t offset, struct fuse_file_info *fi)
|
||||||
struct fuse_file_info *fi) -> int;
|
-> int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] static auto release_(const char *path,
|
[[nodiscard]] static auto release_(const char *path,
|
||||||
@ -207,8 +207,8 @@ private:
|
|||||||
[[nodiscard]] static auto listxattr_(const char *path, char *buffer,
|
[[nodiscard]] static auto listxattr_(const char *path, char *buffer,
|
||||||
size_t size) -> int;
|
size_t size) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto removexattr_(const char *path,
|
[[nodiscard]] static auto removexattr_(const char *path, const char *name)
|
||||||
const char *name) -> int;
|
-> int;
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
||||||
@ -217,17 +217,18 @@ private:
|
|||||||
|
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
||||||
const char *value, size_t size,
|
const char *value, size_t size, int flags)
|
||||||
int flags) -> int;
|
-> int;
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // HAS_SETXATTR
|
#endif // HAS_SETXATTR
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] static auto setattr_x_(const char *path,
|
[[nodiscard]] static auto setattr_x_(const char *path, struct setattr_x *attr)
|
||||||
struct setattr_x *attr) -> int;
|
-> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto
|
[[nodiscard]] static auto setbkuptime_(const char *path,
|
||||||
setbkuptime_(const char *path, const struct timespec *bkuptime) -> int;
|
const struct timespec *bkuptime)
|
||||||
|
-> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto setchgtime_(const char *path,
|
[[nodiscard]] static auto setchgtime_(const char *path,
|
||||||
const struct timespec *chgtime) -> int;
|
const struct timespec *chgtime) -> int;
|
||||||
@ -237,12 +238,12 @@ private:
|
|||||||
|
|
||||||
[[nodiscard]] static auto setvolname_(const char *volname) -> int;
|
[[nodiscard]] static auto setvolname_(const char *volname) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto statfs_x_(const char *path,
|
[[nodiscard]] static auto statfs_x_(const char *path, struct statfs *stbuf)
|
||||||
struct statfs *stbuf) -> int;
|
-> int;
|
||||||
|
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] static auto statfs_(const char *path,
|
[[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf)
|
||||||
struct statvfs *stbuf) -> int;
|
-> int;
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
@ -268,8 +269,8 @@ private:
|
|||||||
struct fuse_file_info *fi) -> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/)
|
||||||
int /*mask*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +282,10 @@ protected:
|
|||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/,
|
||||||
chmod_impl(std::string /*api_path*/, mode_t /*mode*/,
|
mode_t /*mode*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -294,9 +296,10 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/,
|
||||||
chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/,
|
gid_t /*gid*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -306,9 +309,10 @@ protected:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto create_impl(std::string /*api_path*/,
|
||||||
create_impl(std::string /*api_path*/, mode_t /*mode*/,
|
mode_t /*mode*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,43 +320,48 @@ protected:
|
|||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/,
|
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/,
|
||||||
off_t /*length*/,
|
off_t /*length*/, struct fuse_file_info * /*fi*/)
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/,
|
||||||
fgetattr_impl(std::string /*api_path*/, struct stat * /*st*/,
|
struct stat * /*st*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/,
|
||||||
fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/,
|
struct setattr_x * /*attr*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/,
|
||||||
fsync_impl(std::string /*api_path*/, int /*datasync*/,
|
int /*datasync*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FUSE_USE_VERSION < 30
|
#if FUSE_USE_VERSION < 30
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/,
|
||||||
ftruncate_impl(std::string /*api_path*/, off_t /*size*/,
|
off_t /*size*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/,
|
||||||
getattr_impl(std::string /*api_path*/, struct stat * /*st*/,
|
struct stat * /*st*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -363,16 +372,17 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/,
|
||||||
getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/,
|
struct timespec * /*bkuptime*/,
|
||||||
struct timespec * /*crtime*/) -> api_error {
|
struct timespec * /*crtime*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
virtual auto init_impl(struct fuse_conn_info *conn,
|
virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
||||||
struct fuse_config *cfg) -> void *;
|
-> void *;
|
||||||
#else
|
#else
|
||||||
virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
|
virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
|
||||||
#endif
|
#endif
|
||||||
@ -382,15 +392,15 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto open_impl(std::string /*api_path*/,
|
||||||
open_impl(std::string /*api_path*/,
|
struct fuse_file_info * /*fi*/)
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/,
|
||||||
opendir_impl(std::string /*api_path*/,
|
struct fuse_file_info * /*fi*/)
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,8 +415,8 @@ protected:
|
|||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
readdir_impl(std::string /*api_path*/, void * /*buf*/,
|
readdir_impl(std::string /*api_path*/, void * /*buf*/,
|
||||||
fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/,
|
fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/,
|
||||||
struct fuse_file_info * /*fi*/,
|
struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/)
|
||||||
fuse_readdir_flags /*flags*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -418,15 +428,15 @@ protected:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto release_impl(std::string /*api_path*/,
|
||||||
release_impl(std::string /*api_path*/,
|
struct fuse_file_info * /*fi*/)
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/,
|
||||||
releasedir_impl(std::string /*api_path*/,
|
struct fuse_file_info * /*fi*/)
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,9 +447,9 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/,
|
||||||
rename_impl(std::string /*from_api_path*/,
|
std::string /*to_api_path*/)
|
||||||
std::string /*to_api_path*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -459,8 +469,8 @@ protected:
|
|||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
getxattr_impl(std::string /*api_path*/, const char * /*name*/,
|
getxattr_impl(std::string /*api_path*/, const char * /*name*/,
|
||||||
char * /*value*/, size_t /*size*/,
|
char * /*value*/, size_t /*size*/, int & /*attribute_size*/)
|
||||||
int & /*attribute_size*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
@ -471,9 +481,9 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto removexattr_impl(std::string /*api_path*/,
|
||||||
removexattr_impl(std::string /*api_path*/,
|
const char * /*name*/)
|
||||||
const char * /*name*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,20 +496,19 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
const char * /*name*/,
|
setxattr_impl(std::string /*api_path*/, const char * /*name*/,
|
||||||
const char * /*value*/,
|
const char * /*value*/, size_t /*size*/, int /*flags*/)
|
||||||
size_t /*size*/,
|
-> api_error {
|
||||||
int /*flags*/) -> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // HAS_SETXATTR
|
#endif // HAS_SETXATTR
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/,
|
||||||
setattr_x_impl(std::string /*api_path*/,
|
struct setattr_x * /*attr*/)
|
||||||
struct setattr_x * /*attr*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,39 +519,40 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
setchgtime_impl(std::string /*api_path*/,
|
setchgtime_impl(std::string /*api_path*/, const struct timespec * /*chgtime*/)
|
||||||
const struct timespec * /*chgtime*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto setcrtime_impl(std::string /*api_path*/,
|
||||||
setcrtime_impl(std::string /*api_path*/,
|
const struct timespec * /*crtime*/)
|
||||||
const struct timespec * /*crtime*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto setvolname_impl(const char * /*volname*/)
|
||||||
setvolname_impl(const char * /*volname*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto statfs_x_impl(std::string /*api_path*/,
|
||||||
statfs_x_impl(std::string /*api_path*/,
|
struct statfs * /*stbuf*/)
|
||||||
struct statfs * /*stbuf*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/,
|
||||||
statfs_impl(std::string /*api_path*/,
|
struct statvfs * /*stbuf*/)
|
||||||
struct statvfs * /*stbuf*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/,
|
||||||
truncate_impl(std::string /*api_path*/, off_t /*size*/,
|
off_t /*size*/,
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -552,21 +562,22 @@ protected:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto unlink_impl(std::string /*api_path*/)
|
||||||
unlink_impl(std::string /*api_path*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
|
||||||
utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2],
|
const struct timespec /*tv*/[2],
|
||||||
struct fuse_file_info * /*fi*/) -> api_error {
|
struct fuse_file_info * /*fi*/)
|
||||||
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
|
||||||
utimens_impl(std::string /*api_path*/,
|
const struct timespec /*tv*/[2])
|
||||||
const struct timespec /*tv*/[2]) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -574,8 +585,8 @@ protected:
|
|||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
write_impl(std::string /*api_path*/, const char * /*buffer*/,
|
write_impl(std::string /*api_path*/, const char * /*buffer*/,
|
||||||
size_t /*write_size*/, off_t /*write_offset*/,
|
size_t /*write_size*/, off_t /*write_offset*/,
|
||||||
struct fuse_file_info * /*fi*/,
|
struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/)
|
||||||
std::size_t & /*bytes_written*/) -> api_error {
|
-> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "comm/packet/packet_client.hpp"
|
#include "comm/packet/packet_client.hpp"
|
||||||
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "types/remote.hpp"
|
#include "types/remote.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "drives/fuse/fuse_base.hpp"
|
#include "drives/fuse/fuse_base.hpp"
|
||||||
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class app_config;
|
class app_config;
|
||||||
|
@ -29,8 +29,11 @@
|
|||||||
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
||||||
#include "drives/remote/remote_open_file_table.hpp"
|
#include "drives/remote/remote_open_file_table.hpp"
|
||||||
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "types/remote.hpp"
|
#include "types/remote.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/base64.hpp"
|
#include "utils/base64.hpp"
|
||||||
@ -55,7 +58,7 @@ public:
|
|||||||
drive_(drv),
|
drive_(drv),
|
||||||
mount_location_(std::move(mount_location)),
|
mount_location_(std::move(mount_location)),
|
||||||
client_pool_(config.get_remote_mount().client_pool_size) {
|
client_pool_(config.get_remote_mount().client_pool_size) {
|
||||||
event_system::instance().raise<service_started>("remote_server_base");
|
event_system2::instance().raise<service_start_begin>("remote_server_base");
|
||||||
handler_lookup_.insert(
|
handler_lookup_.insert(
|
||||||
{"::winfsp_can_delete",
|
{"::winfsp_can_delete",
|
||||||
[this](std::uint32_t, const std::string &, std::uint64_t,
|
[this](std::uint32_t, const std::string &, std::uint64_t,
|
||||||
@ -1372,14 +1375,14 @@ public:
|
|||||||
method, request, response,
|
method, request, response,
|
||||||
message_complete);
|
message_complete);
|
||||||
});
|
});
|
||||||
|
event_system2::instance().raise<service_start_end>("remote_server_base");
|
||||||
}
|
}
|
||||||
|
|
||||||
~remote_server_base() override {
|
~remote_server_base() override {
|
||||||
event_system::instance().raise<service_shutdown_begin>(
|
event_system2::instance().raise<service_stop_begin>("remote_server_base");
|
||||||
"remote_server_base");
|
|
||||||
client_pool_.shutdown();
|
client_pool_.shutdown();
|
||||||
packet_server_.reset();
|
packet_server_.reset();
|
||||||
event_system::instance().raise<service_shutdown_end>("remote_server_base");
|
event_system2::instance().raise<service_stop_end>("remote_server_base");
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class app_config;
|
class app_config;
|
||||||
@ -32,13 +32,13 @@ class lock_data;
|
|||||||
class server;
|
class server;
|
||||||
namespace remote_winfsp {
|
namespace remote_winfsp {
|
||||||
class remote_winfsp_drive final : public virtual FileSystemBase {
|
class remote_winfsp_drive final : public virtual FileSystemBase {
|
||||||
E_CONSUMER();
|
E_CONSUMER2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
remote_winfsp_drive(app_config &config, remote_instance_factory factory,
|
remote_winfsp_drive(app_config &config, remote_instance_factory factory,
|
||||||
lock_data &lock);
|
lock_data &lock);
|
||||||
|
|
||||||
~remote_winfsp_drive() override { E_CONSUMER_RELEASE(); }
|
~remote_winfsp_drive() override { E_CONSUMER2_RELEASE(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class winfsp_service : virtual public Service {
|
class winfsp_service : virtual public Service {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "drives/eviction.hpp"
|
#include "drives/eviction.hpp"
|
||||||
#include "drives/winfsp/i_winfsp_drive.hpp"
|
#include "drives/winfsp/i_winfsp_drive.hpp"
|
||||||
#include "drives/winfsp/remotewinfsp/remote_server.hpp"
|
#include "drives/winfsp/remotewinfsp/remote_server.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "file_manager/file_manager.hpp"
|
#include "file_manager/file_manager.hpp"
|
||||||
#include "rpc/server/full_server.hpp"
|
#include "rpc/server/full_server.hpp"
|
||||||
|
|
||||||
@ -37,12 +37,12 @@ class i_provider;
|
|||||||
|
|
||||||
class winfsp_drive final : public virtual i_winfsp_drive,
|
class winfsp_drive final : public virtual i_winfsp_drive,
|
||||||
public virtual FileSystemBase {
|
public virtual FileSystemBase {
|
||||||
E_CONSUMER();
|
E_CONSUMER2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
winfsp_drive(app_config &config, lock_data &lockData, i_provider &provider);
|
winfsp_drive(app_config &config, lock_data &lockData, i_provider &provider);
|
||||||
|
|
||||||
~winfsp_drive() override { E_CONSUMER_RELEASE(); }
|
~winfsp_drive() override { E_CONSUMER2_RELEASE(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class winfsp_service final : virtual public Service {
|
class winfsp_service final : virtual public Service {
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||||
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class console_consumer final {
|
class console_consumer final {
|
||||||
E_CONSUMER();
|
|
||||||
E_CONSUMER2();
|
E_CONSUMER2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -38,8 +37,6 @@ public:
|
|||||||
~console_consumer();
|
~console_consumer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void process_event(const event &evt);
|
|
||||||
|
|
||||||
static void process_event2(const i_event &evt);
|
static void process_event2(const i_event &evt);
|
||||||
};
|
};
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
#ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||||
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
#define REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class logging_consumer {
|
class logging_consumer final {
|
||||||
E_CONSUMER();
|
|
||||||
E_CONSUMER2();
|
E_CONSUMER2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -41,8 +40,6 @@ private:
|
|||||||
5ULL};
|
5ULL};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void process_event(const event &evt);
|
|
||||||
|
|
||||||
static void process_event2(const i_event &evt);
|
static void process_event2(const i_event &evt);
|
||||||
};
|
};
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
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_EVENT_HPP_
|
|
||||||
#define REPERTORY_INCLUDE_EVENTS_EVENT_HPP_
|
|
||||||
|
|
||||||
#include "types/repertory.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
|
||||||
class event {
|
|
||||||
protected:
|
|
||||||
event() = default;
|
|
||||||
|
|
||||||
event(const std::stringstream &ss, json j)
|
|
||||||
: ss_(ss.str()), j_(std::move(j)) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
event(const event &) = delete;
|
|
||||||
event(event &&) = delete;
|
|
||||||
auto operator=(const event &) -> event & = delete;
|
|
||||||
auto operator=(event &&) -> event & = delete;
|
|
||||||
virtual ~event() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::stringstream ss_;
|
|
||||||
json j_{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
[[nodiscard]] virtual auto clone() const -> std::shared_ptr<event> = 0;
|
|
||||||
|
|
||||||
[[nodiscard]] virtual auto get_event_level() const -> event_level = 0;
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_json() const -> json { return j_; }
|
|
||||||
|
|
||||||
[[nodiscard]] virtual auto get_name() const -> std::string = 0;
|
|
||||||
|
|
||||||
[[nodiscard]] virtual auto get_single_line() const -> std::string = 0;
|
|
||||||
};
|
|
||||||
} // namespace repertory
|
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_EVENTS_EVENT_HPP_
|
|
@ -1,232 +0,0 @@
|
|||||||
/*
|
|
||||||
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_EVENT_SYSTEM_HPP_
|
|
||||||
#define REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
|
|
||||||
|
|
||||||
#include "events/event.hpp"
|
|
||||||
#include "events/t_event_system.hpp"
|
|
||||||
#include "types/repertory.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
|
||||||
using event_system = t_event_system<event>;
|
|
||||||
using event_consumer = event_system::event_consumer;
|
|
||||||
|
|
||||||
#define E_FROM_API_FILE_ERROR(e) api_error_to_string(e)
|
|
||||||
#define E_FROM_BOOL(t) std::to_string(t)
|
|
||||||
#define E_FROM_CURL_CODE(t) std::string(curl_easy_strerror(t))
|
|
||||||
#define E_FROM_DOUBLE(d) std::to_string(d)
|
|
||||||
#define E_FROM_DOUBLE_PRECISE(dbl_val) \
|
|
||||||
([](const double &d) -> std::string { \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << std::fixed << std::setprecision(2) << d; \
|
|
||||||
return ss.str(); \
|
|
||||||
})(dbl_val)
|
|
||||||
#define E_FROM_INT32(t) std::to_string(t)
|
|
||||||
#define E_FROM_SIZE_T(t) std::to_string(t)
|
|
||||||
#define E_FROM_STRING(t) t
|
|
||||||
#define E_FROM_UINT16(t) std::to_string(t)
|
|
||||||
#define E_FROM_UINT64(t) std::to_string(t)
|
|
||||||
#define E_FROM_DOWNLOAD_TYPE(t) download_type_to_string(t)
|
|
||||||
|
|
||||||
#define E_PROP(type, name, short_name, ts) \
|
|
||||||
private: \
|
|
||||||
void init_##short_name(const type &val) { \
|
|
||||||
auto ts_val = ts(val); \
|
|
||||||
ss_ << "|" << #short_name << "|" << ts_val; \
|
|
||||||
j_[#name] = ts_val; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
[[nodiscard]] auto get_##name() const->json { return j_[#name]; }
|
|
||||||
|
|
||||||
#define E_BEGIN(name, el) \
|
|
||||||
class name final : public virtual event { \
|
|
||||||
private: \
|
|
||||||
name(const std::stringstream &ss, const json &j) : event(ss, j) {} \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
~name() override = default; \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
static const event_level level = event_level::el; \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
[[nodiscard]] auto get_name() const -> std::string override { \
|
|
||||||
return #name; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
[[nodiscard]] auto get_event_level() const -> event_level override { \
|
|
||||||
return name::level; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
[[nodiscard]] auto get_single_line() const -> std::string override { \
|
|
||||||
const auto s = ss_.str(); \
|
|
||||||
return get_name() + (s.empty() ? "" : s); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
[[nodiscard]] auto clone() const -> std::shared_ptr<event> override { \
|
|
||||||
return std::shared_ptr<name>(new name(ss_, j_)); \
|
|
||||||
}
|
|
||||||
#define E_END() }
|
|
||||||
|
|
||||||
#define E_SIMPLE(event_name, el) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
public: \
|
|
||||||
event_name() {} \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE1(event_name, el, type, name, short_name, tc) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv) { init_##short_name(tv); } \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE2(event_name, el, type, name, short_name, tc, type2, name2, \
|
|
||||||
short_name2, tc2) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv, const type2 &tv2) { \
|
|
||||||
init_##short_name(tv); \
|
|
||||||
init_##short_name2(tv2); \
|
|
||||||
} \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_PROP(type2, name2, short_name2, tc2) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE3(event_name, el, type, name, short_name, tc, type2, name2, \
|
|
||||||
short_name2, tc2, type3, name3, short_name3, tc3) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3) { \
|
|
||||||
init_##short_name(tv); \
|
|
||||||
init_##short_name2(tv2); \
|
|
||||||
init_##short_name3(tv3); \
|
|
||||||
} \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_PROP(type2, name2, short_name2, tc2) \
|
|
||||||
E_PROP(type3, name3, short_name3, tc3) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE4(event_name, el, type, name, short_name, tc, type2, name2, \
|
|
||||||
short_name2, tc2, type3, name3, short_name3, tc3, type4, \
|
|
||||||
name4, short_name4, tc4) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
|
|
||||||
const type4 &tv4) { \
|
|
||||||
init_##short_name(tv); \
|
|
||||||
init_##short_name2(tv2); \
|
|
||||||
init_##short_name3(tv3); \
|
|
||||||
init_##short_name4(tv4); \
|
|
||||||
} \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_PROP(type2, name2, short_name2, tc2) \
|
|
||||||
E_PROP(type3, name3, short_name3, tc3) \
|
|
||||||
E_PROP(type4, name4, short_name4, tc4) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE5(event_name, el, type, name, short_name, tc, type2, name2, \
|
|
||||||
short_name2, tc2, type3, name3, short_name3, tc3, type4, \
|
|
||||||
name4, short_name4, tc4, type5, name5, short_name5, tc5) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
|
|
||||||
const type4 &tv4, const type5 &tv5) { \
|
|
||||||
init_##short_name(tv); \
|
|
||||||
init_##short_name2(tv2); \
|
|
||||||
init_##short_name3(tv3); \
|
|
||||||
init_##short_name4(tv4); \
|
|
||||||
init_##short_name5(tv5); \
|
|
||||||
} \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_PROP(type2, name2, short_name2, tc2) \
|
|
||||||
E_PROP(type3, name3, short_name3, tc3) \
|
|
||||||
E_PROP(type4, name4, short_name4, tc4) \
|
|
||||||
E_PROP(type5, name5, short_name5, tc5) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE6(event_name, el, type, name, short_name, tc, type2, name2, \
|
|
||||||
short_name2, tc2, type3, name3, short_name3, tc3, type4, \
|
|
||||||
name4, short_name4, tc4, type5, name5, short_name5, tc5, \
|
|
||||||
type6, name6, short_name6, tc6) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
|
|
||||||
const type4 &tv4, const type5 &tv5, const type6 &tv6) { \
|
|
||||||
init_##short_name(tv); \
|
|
||||||
init_##short_name2(tv2); \
|
|
||||||
init_##short_name3(tv3); \
|
|
||||||
init_##short_name4(tv4); \
|
|
||||||
init_##short_name5(tv5); \
|
|
||||||
init_##short_name6(tv6); \
|
|
||||||
} \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_PROP(type2, name2, short_name2, tc2) \
|
|
||||||
E_PROP(type3, name3, short_name3, tc3) \
|
|
||||||
E_PROP(type4, name4, short_name4, tc4) \
|
|
||||||
E_PROP(type5, name5, short_name5, tc5) \
|
|
||||||
E_PROP(type6, name6, short_name6, tc6) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_SIMPLE7(event_name, el, type, name, short_name, tc, type2, name2, \
|
|
||||||
short_name2, tc2, type3, name3, short_name3, tc3, type4, \
|
|
||||||
name4, short_name4, tc4, type5, name5, short_name5, tc5, \
|
|
||||||
type6, name6, short_name6, tc6, type7, name7, short_name7, \
|
|
||||||
tc7) \
|
|
||||||
E_BEGIN(event_name, el) \
|
|
||||||
explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \
|
|
||||||
const type4 &tv4, const type5 &tv5, const type6 &tv6, \
|
|
||||||
const type7 &tv7) { \
|
|
||||||
init_##short_name(tv); \
|
|
||||||
init_##short_name2(tv2); \
|
|
||||||
init_##short_name3(tv3); \
|
|
||||||
init_##short_name4(tv4); \
|
|
||||||
init_##short_name5(tv5); \
|
|
||||||
init_##short_name6(tv6); \
|
|
||||||
init_##short_name7(tv7); \
|
|
||||||
} \
|
|
||||||
E_PROP(type, name, short_name, tc) \
|
|
||||||
E_PROP(type2, name2, short_name2, tc2) \
|
|
||||||
E_PROP(type3, name3, short_name3, tc3) \
|
|
||||||
E_PROP(type4, name4, short_name4, tc4) \
|
|
||||||
E_PROP(type5, name5, short_name5, tc5) \
|
|
||||||
E_PROP(type6, name6, short_name6, tc6) \
|
|
||||||
E_PROP(type7, name7, short_name7, tc7) \
|
|
||||||
E_END()
|
|
||||||
|
|
||||||
#define E_CONSUMER() \
|
|
||||||
private: \
|
|
||||||
std::vector<std::shared_ptr<repertory::event_consumer>> event_consumers_
|
|
||||||
|
|
||||||
#define E_CONSUMER_RELEASE() event_consumers_.clear()
|
|
||||||
|
|
||||||
#define E_SUBSCRIBE(name, callback) \
|
|
||||||
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
|
||||||
#name, [this](const event &evt) { callback(evt); }))
|
|
||||||
|
|
||||||
#define E_SUBSCRIBE_EXACT(name, callback) \
|
|
||||||
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
|
||||||
#name, [this](const event &evt) { \
|
|
||||||
callback(dynamic_cast<const name &>(evt)); \
|
|
||||||
}))
|
|
||||||
|
|
||||||
#define E_SUBSCRIBE_ALL(callback) \
|
|
||||||
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
|
||||||
[this](const event &evt) { callback(evt); }))
|
|
||||||
} // namespace repertory
|
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_
|
|
@ -120,6 +120,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
using event_consumer2 = event_system2::event_consumer2;
|
using event_consumer2 = event_system2::event_consumer2;
|
||||||
|
using event_consumer = event_system2::event_consumer2;
|
||||||
|
|
||||||
#define E_CONSUMER2() \
|
#define E_CONSUMER2() \
|
||||||
private: \
|
private: \
|
||||||
|
@ -28,210 +28,6 @@
|
|||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
E_SIMPLE1(failed_upload_queued, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(failed_upload_removed, warn,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(failed_upload_retry, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_get_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(file_get_api_list_failed, error,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(file_pinned, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(file_read_bytes_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING,
|
|
||||||
std::size_t, retry, retry, E_FROM_SIZE_T
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(file_removed, debug,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_removed_externally, warn,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_remove_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(file_rename_failed, error,
|
|
||||||
std::string, from_api_path, FROM, E_FROM_STRING,
|
|
||||||
std::string, to_api_path, TO, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_get_size_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(filesystem_item_added, debug,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, parent, parent, E_FROM_STRING,
|
|
||||||
bool, directory, dir, E_FROM_BOOL
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE4(filesystem_item_closed, trace,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
bool, directory, dir, E_FROM_BOOL,
|
|
||||||
bool, changed, changed, E_FROM_BOOL
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE5(filesystem_item_handle_closed, trace,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::uint64_t, handle, handle, E_FROM_UINT64,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
bool, directory, dir, E_FROM_BOOL,
|
|
||||||
bool, changed, changed, E_FROM_BOOL
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE4(filesystem_item_handle_opened, trace,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::uint64_t, handle, handle, E_FROM_UINT64,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
bool, directory, dir, E_FROM_BOOL
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(filesystem_item_evicted, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(filesystem_item_opened, trace,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
bool, directory, dir, E_FROM_BOOL
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(file_unpinned, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE4(file_upload_completed, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
api_error, result, res, E_FROM_API_FILE_ERROR,
|
|
||||||
bool, cancelled, cancel, E_FROM_BOOL
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(file_upload_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_upload_not_found, warn,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_upload_queued, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(file_upload_removed, debug,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(file_upload_retry, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
api_error, result, res, E_FROM_API_FILE_ERROR
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(file_upload_started, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(orphaned_file_deleted, warn,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(orphaned_file_detected, warn,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(orphaned_file_processing_failed, error,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
std::string, dest, dest, E_FROM_STRING,
|
|
||||||
std::string, result, res, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(orphaned_source_file_detected, info,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(orphaned_source_file_removed, info,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(polling_item_begin, debug,
|
|
||||||
std::string, item_name, item, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(polling_item_end, debug,
|
|
||||||
std::string, item_name, item, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(provider_offline, error,
|
|
||||||
std::string, host_name_or_ip, host, E_FROM_STRING,
|
|
||||||
std::uint16_t, port, port, E_FROM_UINT16
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(provider_upload_begin, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(provider_upload_end, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
api_error, result, res, E_FROM_API_FILE_ERROR
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(repertory_exception, error,
|
|
||||||
std::string, function, func, E_FROM_STRING,
|
|
||||||
std::string, message, msg, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(rpc_server_exception, error,
|
|
||||||
std::string, exception, exception, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(service_shutdown_begin, debug,
|
|
||||||
std::string, service, svc, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(service_shutdown_end, debug,
|
|
||||||
std::string, service, svc, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(service_started, debug,
|
|
||||||
std::string, service, svc, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE(unmount_requested, info);
|
E_SIMPLE(unmount_requested, info);
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
E_SIMPLE2(unmount_result, info,
|
E_SIMPLE2(unmount_result, info,
|
||||||
@ -239,6 +35,70 @@ E_SIMPLE2(unmount_result, info,
|
|||||||
std::string, result, res, E_FROM_STRING
|
std::string, result, res, E_FROM_STRING
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
E_SIMPLE2(download_begin, info,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE3(download_end, info,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING,
|
||||||
|
api_error, result, result, E_FROM_API_FILE_ERROR
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE3(download_progress, info,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING,
|
||||||
|
double, progress, prog, E_FROM_DOUBLE_PRECISE
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE2(download_restored, info,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE3(download_restore_failed, error,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING,
|
||||||
|
std::string, error, err, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE3(download_resume_add_failed, error,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING,
|
||||||
|
std::string, error, err, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE2(download_resume_added, debug,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE2(download_resume_removed, debug,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, dest_path, dest, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE1(item_timeout, trace,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE3(download_type_selected, debug,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
std::string, source, src, E_FROM_STRING,
|
||||||
|
download_type, download_type, type, E_FROM_DOWNLOAD_TYPE
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE3(fuse_event, debug,
|
||||||
|
std::string, function, func, E_FROM_STRING,
|
||||||
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
|
int, result, res, E_FROM_INT32
|
||||||
|
);
|
||||||
|
|
||||||
|
E_SIMPLE1(fuse_args_parsed, info,
|
||||||
|
std::string, arguments, args, E_FROM_STRING
|
||||||
|
);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
|
@ -1,249 +0,0 @@
|
|||||||
/*
|
|
||||||
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_T_EVENT_SYSTEM_HPP_
|
|
||||||
#define REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
|
||||||
|
|
||||||
#include "app_config.hpp"
|
|
||||||
#include "events/event.hpp"
|
|
||||||
#include "utils/collection.hpp"
|
|
||||||
#include "utils/utils.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
|
||||||
template <typename event_type> class t_event_system final {
|
|
||||||
private:
|
|
||||||
static constexpr const std::uint8_t max_queue_retry{
|
|
||||||
30U,
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::uint32_t max_queue_size{
|
|
||||||
std::thread::hardware_concurrency() * 4U,
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr const std::chrono::seconds queue_wait_secs{
|
|
||||||
5s,
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
t_event_system(const t_event_system &) = delete;
|
|
||||||
t_event_system(t_event_system &&) = delete;
|
|
||||||
auto operator=(const t_event_system &) -> t_event_system & = delete;
|
|
||||||
auto operator=(t_event_system &&) -> t_event_system & = delete;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
t_event_system() = default;
|
|
||||||
|
|
||||||
~t_event_system() { stop(); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
class event_consumer final {
|
|
||||||
public:
|
|
||||||
explicit event_consumer(std::function<void(const event &)> callback)
|
|
||||||
: callback_(std::move(callback)) {
|
|
||||||
t_event_system::instance().attach(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
event_consumer(const std::string &event_name,
|
|
||||||
std::function<void(const event &)> callback)
|
|
||||||
: callback_(std::move(callback)) {
|
|
||||||
t_event_system::instance().attach(event_name, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
~event_consumer() { t_event_system::instance().release(this); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
event_consumer(const event_consumer &) = delete;
|
|
||||||
event_consumer(event_consumer &&) = delete;
|
|
||||||
auto operator=(const event_consumer &) -> event_consumer & = delete;
|
|
||||||
auto operator=(event_consumer &&) -> event_consumer & = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::function<void(const event &)> callback_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void notify_event(const event &event) { callback_(event); }
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
static t_event_system event_system_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static auto instance() -> t_event_system &;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unordered_map<std::string, std::deque<event_consumer *>>
|
|
||||||
event_consumers_;
|
|
||||||
std::recursive_mutex consumer_mutex_;
|
|
||||||
std::vector<std::shared_ptr<event_type>> event_list_;
|
|
||||||
std::condition_variable event_notify_;
|
|
||||||
std::mutex event_mutex_;
|
|
||||||
std::unique_ptr<std::thread> event_thread_;
|
|
||||||
std::mutex run_mutex_;
|
|
||||||
stop_type stop_requested_{false};
|
|
||||||
|
|
||||||
private:
|
|
||||||
[[nodiscard]] auto get_stop_requested() const -> bool {
|
|
||||||
return stop_requested_ || app_config::get_stop_requested();
|
|
||||||
}
|
|
||||||
|
|
||||||
void process_events() {
|
|
||||||
std::vector<std::shared_ptr<event_type>> events;
|
|
||||||
|
|
||||||
unique_mutex_lock lock(event_mutex_);
|
|
||||||
const auto lock_and_notify = [this, &lock]() {
|
|
||||||
lock.lock();
|
|
||||||
event_notify_.notify_all();
|
|
||||||
lock.unlock();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (not get_stop_requested() && event_list_.empty()) {
|
|
||||||
event_notify_.wait_for(lock, queue_wait_secs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not event_list_.empty()) {
|
|
||||||
events.insert(events.end(), event_list_.begin(), event_list_.end());
|
|
||||||
event_list_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
if (events.empty()) {
|
|
||||||
lock_and_notify();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto notify_events = [this](const std::string &name,
|
|
||||||
const event_type &event) {
|
|
||||||
std::deque<std::future<void>> futures;
|
|
||||||
recur_mutex_lock consumer_lock(consumer_mutex_);
|
|
||||||
for (auto *consumer : event_consumers_[name]) {
|
|
||||||
futures.emplace_back(
|
|
||||||
std::async(std::launch::async, [consumer, &event]() {
|
|
||||||
consumer->notify_event(event);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
while (not futures.empty()) {
|
|
||||||
futures.front().get();
|
|
||||||
futures.pop_front();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto &evt : events) {
|
|
||||||
notify_events("", *evt.get());
|
|
||||||
notify_events(evt->get_name(), *evt.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
lock_and_notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
void queue_event(std::shared_ptr<event_type> evt) {
|
|
||||||
unique_mutex_lock lock(event_mutex_);
|
|
||||||
event_list_.push_back(std::move(evt));
|
|
||||||
auto size = event_list_.size();
|
|
||||||
event_notify_.notify_all();
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
for (std::uint8_t retry{0U};
|
|
||||||
size > max_queue_size && retry < max_queue_retry &&
|
|
||||||
not get_stop_requested();
|
|
||||||
++retry) {
|
|
||||||
lock.lock();
|
|
||||||
size = event_list_.size();
|
|
||||||
if (size > max_queue_size) {
|
|
||||||
event_notify_.wait_for(lock, queue_wait_secs);
|
|
||||||
size = event_list_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
event_notify_.notify_all();
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
void attach(event_consumer *consumer) {
|
|
||||||
recur_mutex_lock lock(consumer_mutex_);
|
|
||||||
event_consumers_[""].push_back(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void attach(const std::string &event_name, event_consumer *consumer) {
|
|
||||||
recur_mutex_lock lock(consumer_mutex_);
|
|
||||||
event_consumers_[event_name].push_back(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename event_t, typename... arg_t> void raise(arg_t &&...args) {
|
|
||||||
queue_event(std::make_shared<event_t>(std::forward<arg_t>(args)...));
|
|
||||||
}
|
|
||||||
|
|
||||||
void release(event_consumer *consumer) {
|
|
||||||
recur_mutex_lock lock(consumer_mutex_);
|
|
||||||
auto iter = std::find_if(event_consumers_.begin(), event_consumers_.end(),
|
|
||||||
[&](const auto &item) -> bool {
|
|
||||||
return utils::collection::includes(item.second,
|
|
||||||
consumer);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (iter != event_consumers_.end()) {
|
|
||||||
utils::collection::remove_element((*iter).second, consumer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void start() {
|
|
||||||
mutex_lock lock(run_mutex_);
|
|
||||||
if (event_thread_) {
|
|
||||||
event_notify_.notify_all();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_requested_ = false;
|
|
||||||
|
|
||||||
event_thread_ = std::make_unique<std::thread>([this]() {
|
|
||||||
while (not get_stop_requested()) {
|
|
||||||
process_events();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
event_notify_.notify_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop() {
|
|
||||||
unique_mutex_lock lock(run_mutex_);
|
|
||||||
if (not event_thread_) {
|
|
||||||
event_notify_.notify_all();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_requested_ = true;
|
|
||||||
|
|
||||||
std::unique_ptr<std::thread> thread{nullptr};
|
|
||||||
std::swap(thread, event_thread_);
|
|
||||||
|
|
||||||
event_notify_.notify_all();
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
thread->join();
|
|
||||||
thread.reset();
|
|
||||||
|
|
||||||
process_events();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace repertory
|
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_
|
|
68
repertory/librepertory/include/events/types/file_pinned.hpp
Normal file
68
repertory/librepertory/include/events/types/file_pinned.hpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_FILE_PINNED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_PINNED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_pinned final : public i_event {
|
||||||
|
file_pinned() = default;
|
||||||
|
file_pinned(std::string api_path_, std::string_view function_name_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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::file_pinned> {
|
||||||
|
static void to_json(json &data, const repertory::file_pinned &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::file_pinned &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_FILE_PINNED_HPP_
|
@ -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_FILE_REMOVE_FAILED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVE_FAILED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_remove_failed final : public i_event {
|
||||||
|
file_remove_failed() = default;
|
||||||
|
file_remove_failed(std::string api_path_, api_error error_,
|
||||||
|
std::string_view function_name_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
error(error_),
|
||||||
|
function_name(std::string(function_name_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_remove_failed"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
api_error error{};
|
||||||
|
std::string function_name;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::error;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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, api_error_to_string(error));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_remove_failed> {
|
||||||
|
static void to_json(json &data, const repertory::file_remove_failed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["error"] = repertory::api_error_to_string(value.error);
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_remove_failed &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
value.error =
|
||||||
|
repertory::api_error_from_string(data.at("error").get<std::string>());
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVE_FAILED_HPP_
|
68
repertory/librepertory/include/events/types/file_removed.hpp
Normal file
68
repertory/librepertory/include/events/types/file_removed.hpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_FILE_REMOVED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_removed final : public i_event {
|
||||||
|
file_removed() = default;
|
||||||
|
file_removed(std::string api_path_, std::string_view function_name_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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::file_removed> {
|
||||||
|
static void to_json(json &data, const repertory::file_removed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::file_removed &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_FILE_REMOVED_HPP_
|
@ -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_FILE_REMOVED_EXTERNALLY_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_EXTERNALLY_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_removed_externally final : public i_event {
|
||||||
|
file_removed_externally() = default;
|
||||||
|
file_removed_externally(std::string api_path_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_removed_externally"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::warn;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|src|{}", name, function_name, api_path,
|
||||||
|
source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_removed_externally> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::file_removed_externally &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_removed_externally &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_EXTERNALLY_HPP_
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_FILE_UNPINNED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UNPINNED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_unpinned final : public i_event {
|
||||||
|
file_unpinned() = default;
|
||||||
|
file_unpinned(std::string api_path_, std::string_view function_name_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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::file_unpinned> {
|
||||||
|
static void to_json(json &data, const repertory::file_unpinned &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::file_unpinned &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_FILE_UNPINNED_HPP_
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
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_FILE_UPLOAD_COMPLETED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_COMPLETED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_upload_completed final : public i_event {
|
||||||
|
file_upload_completed() = default;
|
||||||
|
file_upload_completed(std::string api_path_, bool cancelled_,
|
||||||
|
api_error error_, std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
cancelled(cancelled_),
|
||||||
|
error(error_),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_upload_completed"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
bool cancelled{};
|
||||||
|
api_error error{};
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::info;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|cancelled|{}|error|{}|sp|{}", name,
|
||||||
|
function_name, api_path, cancelled,
|
||||||
|
api_error_to_string(error), source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_upload_completed> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::file_upload_completed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["cancelled"] = value.cancelled;
|
||||||
|
data["error"] = repertory::api_error_to_string(value.error);
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_upload_completed &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("cancelled").get_to<bool>(value.cancelled);
|
||||||
|
value.error =
|
||||||
|
repertory::api_error_from_string(data.at("error").get<std::string>());
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_COMPLETED_HPP_
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
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_FILE_UPLOAD_FAILED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_FAILED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_upload_failed final : public i_event {
|
||||||
|
file_upload_failed() = default;
|
||||||
|
file_upload_failed(std::string api_path_, std::string error_,
|
||||||
|
std::string_view function_name_, std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
error(std::move(error_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_upload_failed"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string error;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::warn;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name,
|
||||||
|
api_path, error, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_upload_failed> {
|
||||||
|
static void to_json(json &data, const repertory::file_upload_failed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["error"] = value.error;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_upload_failed &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("error").get_to<std::string>(value.error);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_FAILED_HPP_
|
@ -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_FILE_UPLOAD_NOT_FOUND_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_NOT_FOUND_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_upload_not_found final : public i_event {
|
||||||
|
file_upload_not_found() = default;
|
||||||
|
file_upload_not_found(std::string api_path_, std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_upload_not_found"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::warn;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name, api_path,
|
||||||
|
source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_upload_not_found> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::file_upload_not_found &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_upload_not_found &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_NOT_FOUND_HPP_
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
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_FILE_UPLOAD_QUEUED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_QUEUED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_upload_queued final : public i_event {
|
||||||
|
file_upload_queued() = default;
|
||||||
|
file_upload_queued(std::string api_path_, std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_upload_queued"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::info;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name, api_path,
|
||||||
|
source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_upload_queued> {
|
||||||
|
static void to_json(json &data, const repertory::file_upload_queued &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_upload_queued &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_QUEUED_HPP_
|
@ -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_FILE_UPLOAD_REMOVED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_REMOVED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_upload_removed final : public i_event {
|
||||||
|
file_upload_removed() = default;
|
||||||
|
file_upload_removed(std::string api_path_, std::string_view function_name_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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::file_upload_removed> {
|
||||||
|
static void to_json(json &data, const repertory::file_upload_removed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::file_upload_removed &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_FILE_UPLOAD_REMOVED_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_FILE_UPLOAD_RETRY_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_RETRY_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct file_upload_retry final : public i_event {
|
||||||
|
file_upload_retry() = default;
|
||||||
|
file_upload_retry(std::string api_path_, std::string error_,
|
||||||
|
std::string_view function_name_, std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
error(std::move(error_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"file_upload_retry"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string error;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::warn;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name,
|
||||||
|
api_path, error, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::file_upload_retry> {
|
||||||
|
static void to_json(json &data, const repertory::file_upload_retry &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["error"] = value.error;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::file_upload_retry &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("error").get_to<std::string>(value.error);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_RETRY_HPP_
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
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_FILESYSTEM_ITEM_ADDED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_ADDED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct filesystem_item_added final : public i_event {
|
||||||
|
filesystem_item_added() = default;
|
||||||
|
filesystem_item_added(std::string api_parent_, std::string api_path_,
|
||||||
|
bool directory_, std::string_view function_name_)
|
||||||
|
: api_parent(std::move(api_parent_)),
|
||||||
|
api_path(std::move(api_path_)),
|
||||||
|
directory(directory_),
|
||||||
|
function_name(std::string(function_name_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"filesystem_item_added"};
|
||||||
|
|
||||||
|
std::string api_parent;
|
||||||
|
std::string api_path;
|
||||||
|
bool directory{};
|
||||||
|
std::string function_name;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|parent|{}|dir|{}", name, function_name,
|
||||||
|
api_path, api_parent, directory);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::filesystem_item_added> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::filesystem_item_added &value) {
|
||||||
|
data["api_parent"] = value.api_parent;
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["directory"] = value.directory;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::filesystem_item_added &value) {
|
||||||
|
data.at("api_parent").get_to<std::string>(value.api_parent);
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("directory").get_to<bool>(value.directory);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_ADDED_HPP_
|
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
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_FILESYSTEM_ITEM_CLOSED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_CLOSED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct filesystem_item_closed final : public i_event {
|
||||||
|
filesystem_item_closed() = default;
|
||||||
|
filesystem_item_closed(std::string api_path_, bool changed_, bool directory_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
changed(changed_),
|
||||||
|
directory(directory_),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"filesystem_item_closed"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
bool changed{};
|
||||||
|
bool directory{};
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|changed|{}|dir|{}|sp|{}", name,
|
||||||
|
function_name, api_path, changed, directory,
|
||||||
|
source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::filesystem_item_closed> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::filesystem_item_closed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["changed"] = value.changed;
|
||||||
|
data["directory"] = value.directory;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::filesystem_item_closed &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("changed").get_to<bool>(value.changed);
|
||||||
|
data.at("directory").get_to<bool>(value.directory);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_CLOSED_HPP_
|
@ -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_FILESYSTEM_ITEM_EVICTED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_EVICTED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct filesystem_item_evicted final : public i_event {
|
||||||
|
filesystem_item_evicted() = default;
|
||||||
|
filesystem_item_evicted(std::string api_path_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"filesystem_item_evicted"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name, api_path,
|
||||||
|
source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::filesystem_item_evicted> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::filesystem_item_evicted &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::filesystem_item_evicted &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_EVICTED_HPP_
|
@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
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_FILESYSTEM_ITEM_HANDLE_CLOSED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_CLOSED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct filesystem_item_handle_closed final : public i_event {
|
||||||
|
filesystem_item_handle_closed() = default;
|
||||||
|
filesystem_item_handle_closed(std::string api_path_, bool changed_,
|
||||||
|
bool directory_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::uint64_t handle_, std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
changed(changed_),
|
||||||
|
directory(directory_),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
handle(handle_),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"filesystem_item_handle_closed"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
bool changed{};
|
||||||
|
bool directory{};
|
||||||
|
std::string function_name;
|
||||||
|
std::uint64_t handle{};
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|changed|{}|dir|{}|handle|{}|sp|{}",
|
||||||
|
name, function_name, api_path, changed, directory,
|
||||||
|
handle, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::filesystem_item_handle_closed> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::filesystem_item_handle_closed &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["changed"] = value.changed;
|
||||||
|
data["directory"] = value.directory;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["handle"] = value.handle;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::filesystem_item_handle_closed &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("changed").get_to<bool>(value.changed);
|
||||||
|
data.at("directory").get_to<bool>(value.directory);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("handle").get_to<std::uint64_t>(value.handle);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_CLOSED_HPP_
|
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
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_FILESYSTEM_ITEM_HANDLE_OPENED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_OPENED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct filesystem_item_handle_opened final : public i_event {
|
||||||
|
filesystem_item_handle_opened() = default;
|
||||||
|
filesystem_item_handle_opened(std::string api_path_, bool directory_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::uint64_t handle_, std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
directory(directory_),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
handle(handle_),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"filesystem_item_handle_opened"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
bool directory{};
|
||||||
|
std::string function_name;
|
||||||
|
std::uint64_t handle{};
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|dir|{}|handle|{}|sp|{}", name,
|
||||||
|
function_name, api_path, directory, handle, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::filesystem_item_handle_opened> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::filesystem_item_handle_opened &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["directory"] = value.directory;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["handle"] = value.handle;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::filesystem_item_handle_opened &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("directory").get_to<bool>(value.directory);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("handle").get_to<std::uint64_t>(value.handle);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_OPENED_HPP_
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
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_FILESYSTEM_ITEM_OPENED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_OPENED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct filesystem_item_opened final : public i_event {
|
||||||
|
filesystem_item_opened() = default;
|
||||||
|
filesystem_item_opened(std::string api_path_, bool directory_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
directory(directory_),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"filesystem_item_opened"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
bool directory{};
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|dir|{}|sp|{}", name, function_name,
|
||||||
|
api_path, directory, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::filesystem_item_opened> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::filesystem_item_opened &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["directory"] = value.directory;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::filesystem_item_opened &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("directory").get_to<bool>(value.directory);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_OPENED_HPP_
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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_ORPHANED_FILE_DETECTED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_DETECTED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct orphaned_file_detected final : public i_event {
|
||||||
|
orphaned_file_detected() = default;
|
||||||
|
orphaned_file_detected(std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|sp|{}", name, function_name, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::orphaned_file_detected> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::orphaned_file_detected &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::orphaned_file_detected &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_DETECTED_HPP_
|
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
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_ORPHANED_FILE_PROCESSING_FAILED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_PROCESSING_FAILED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct orphaned_file_processing_failed final : public i_event {
|
||||||
|
orphaned_file_processing_failed() = default;
|
||||||
|
orphaned_file_processing_failed(std::string dest_path_, std::string error_,
|
||||||
|
std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: dest_path(std::move(dest_path_)),
|
||||||
|
error(std::move(error_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{
|
||||||
|
"orphaned_file_processing_failed"};
|
||||||
|
|
||||||
|
std::string dest_path;
|
||||||
|
std::string error;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::info;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|sp|{}|dp|{}|error|{}", name, function_name,
|
||||||
|
source_path, dest_path, error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::orphaned_file_processing_failed> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::orphaned_file_processing_failed &value) {
|
||||||
|
data["dest_path"] = value.dest_path;
|
||||||
|
data["error"] = value.error;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::orphaned_file_processing_failed &value) {
|
||||||
|
data.at("dest_path").get_to<std::string>(value.dest_path);
|
||||||
|
data.at("error").get_to<std::string>(value.error);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_PROCESSING_FAILED_HPP_
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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_ORPHANED_SOURCE_FILE_DETECTED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_DETECTED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct orphaned_source_file_detected final : public i_event {
|
||||||
|
orphaned_source_file_detected() = default;
|
||||||
|
orphaned_source_file_detected(std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|sp|{}", name, function_name, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::orphaned_source_file_detected> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::orphaned_source_file_detected &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::orphaned_source_file_detected &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_DETECTED_HPP_
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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_ORPHANED_SOURCE_FILE_REMOVED_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_REMOVED_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct orphaned_source_file_removed final : public i_event {
|
||||||
|
orphaned_source_file_removed() = default;
|
||||||
|
orphaned_source_file_removed(std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|sp|{}", name, function_name, source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::orphaned_source_file_removed> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::orphaned_source_file_removed &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::orphaned_source_file_removed &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_REMOVED_HPP_
|
@ -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_POLLING_ITEM_BEGIN_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_BEGIN_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct polling_item_begin final : public i_event {
|
||||||
|
polling_item_begin() = default;
|
||||||
|
polling_item_begin(std::string_view function_name_, std::string item_name_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
item_name(std::move(item_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}", name, function_name, item_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::polling_item_begin> {
|
||||||
|
static void to_json(json &data, const repertory::polling_item_begin &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["item_name"] = value.item_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::polling_item_begin &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("item_name").get_to<std::string>(value.item_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_BEGIN_HPP_
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_POLLING_ITEM_END_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_END_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct polling_item_end final : public i_event {
|
||||||
|
polling_item_end() = default;
|
||||||
|
polling_item_end(std::string_view function_name_, std::string item_name_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
item_name(std::move(item_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}", name, function_name, item_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::polling_item_end> {
|
||||||
|
static void to_json(json &data, const repertory::polling_item_end &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["item_name"] = value.item_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::polling_item_end &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("item_name").get_to<std::string>(value.item_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_END_HPP_
|
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
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_PROVIDER_OFFLINE_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_OFFLINE_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct provider_offline final : public i_event {
|
||||||
|
provider_offline() = default;
|
||||||
|
provider_offline(std::string_view function_name_,
|
||||||
|
std::string host_name_or_ip_, std::uint16_t port_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
host_name_or_ip(std::move(host_name_or_ip_)),
|
||||||
|
port(port_) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"provider_offline"};
|
||||||
|
|
||||||
|
std::string function_name;
|
||||||
|
std::string host_name_or_ip;
|
||||||
|
std::uint16_t port{};
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|host|{}|port|{}", name, function_name,
|
||||||
|
host_name_or_ip, port);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::provider_offline> {
|
||||||
|
static void to_json(json &data, const repertory::provider_offline &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["host_name_or_ip"] = value.host_name_or_ip;
|
||||||
|
data["port"] = value.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::provider_offline &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("host_name_or_ip").get_to<std::string>(value.host_name_or_ip);
|
||||||
|
data.at("port").get_to<std::uint16_t>(value.port);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_OFFLINE_HPP_
|
@ -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_PROVIDER_UPLOAD_BEGIN_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_BEGIN_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct provider_upload_begin final : public i_event {
|
||||||
|
provider_upload_begin() = default;
|
||||||
|
provider_upload_begin(std::string api_path_, std::string_view function_name_,
|
||||||
|
std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"provider_upload_begin"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::warn;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name, api_path,
|
||||||
|
source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::provider_upload_begin> {
|
||||||
|
static void to_json(json &data,
|
||||||
|
const repertory::provider_upload_begin &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::provider_upload_begin &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_BEGIN_HPP_
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
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_PROVIDER_UPLOAD_END_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_END_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct provider_upload_end final : public i_event {
|
||||||
|
provider_upload_end() = default;
|
||||||
|
provider_upload_end(std::string api_path_, api_error error_,
|
||||||
|
std::string_view function_name_, std::string source_path_)
|
||||||
|
: api_path(std::move(api_path_)),
|
||||||
|
error(error_),
|
||||||
|
function_name(std::string(function_name_)),
|
||||||
|
source_path(std::move(source_path_)) {}
|
||||||
|
|
||||||
|
static constexpr const std::string_view name{"provider_upload_end"};
|
||||||
|
|
||||||
|
std::string api_path;
|
||||||
|
api_error error{};
|
||||||
|
std::string function_name;
|
||||||
|
std::string source_path;
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_event_level() const -> event_level override {
|
||||||
|
return event_level::info;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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|{}|sp|{}", name, function_name,
|
||||||
|
api_path, api_error_to_string(error), source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::provider_upload_end> {
|
||||||
|
static void to_json(json &data, const repertory::provider_upload_end &value) {
|
||||||
|
data["api_path"] = value.api_path;
|
||||||
|
data["error"] = repertory::api_error_to_string(value.error);
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["source_path"] = value.source_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::provider_upload_end &value) {
|
||||||
|
data.at("api_path").get_to<std::string>(value.api_path);
|
||||||
|
value.error =
|
||||||
|
repertory::api_error_from_string(data.at("error").get<std::string>());
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("source_path").get_to<std::string>(value.source_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_END_HPP_
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_REPERTORY_EXCEPTION_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_REPERTORY_EXCEPTION_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct repertory_exception final : public i_event {
|
||||||
|
repertory_exception() = default;
|
||||||
|
repertory_exception(std::string_view function_name_, std::string msg_)
|
||||||
|
: function_name(std::string(function_name_)), msg(std::move(msg_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|msg|{}", name, function_name, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::repertory_exception> {
|
||||||
|
static void to_json(json &data, const repertory::repertory_exception &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["msg"] = value.msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::repertory_exception &value) {
|
||||||
|
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_REPERTORY_EXCEPTION_HPP_
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
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_SERVICE_START_BEGIN_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_BEGIN_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct service_start_begin final : public i_event {
|
||||||
|
service_start_begin() = default;
|
||||||
|
service_start_begin(std::string_view function_name_,
|
||||||
|
std::string service_name_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
service_name(std::move(service_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::service_start_begin> {
|
||||||
|
static void to_json(json &data, const repertory::service_start_begin &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["service_name"] = value.service_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::service_start_begin &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("service_name").get_to<std::string>(value.service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_BEGIN_HPP_
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_SERVICE_START_END_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_END_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct service_start_end final : public i_event {
|
||||||
|
service_start_end() = default;
|
||||||
|
service_start_end(std::string_view function_name_, std::string service_name_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
service_name(std::move(service_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::service_start_end> {
|
||||||
|
static void to_json(json &data, const repertory::service_start_end &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["service_name"] = value.service_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::service_start_end &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("service_name").get_to<std::string>(value.service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_END_HPP_
|
@ -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_SERVICE_STOP_BEGIN_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_BEGIN_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct service_stop_begin final : public i_event {
|
||||||
|
service_stop_begin() = default;
|
||||||
|
service_stop_begin(std::string_view function_name_, std::string service_name_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
service_name(std::move(service_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::service_stop_begin> {
|
||||||
|
static void to_json(json &data, const repertory::service_stop_begin &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["service_name"] = value.service_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data,
|
||||||
|
repertory::service_stop_begin &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("service_name").get_to<std::string>(value.service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_BEGIN_HPP_
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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_SERVICE_STOP_END_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_END_HPP_
|
||||||
|
|
||||||
|
#include "events/i_event.hpp"
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
struct service_stop_end final : public i_event {
|
||||||
|
service_stop_end() = default;
|
||||||
|
service_stop_end(std::string_view function_name_, std::string service_name_)
|
||||||
|
: function_name(std::string(function_name_)),
|
||||||
|
service_name(std::move(service_name_)) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_name() const -> std::string_view override {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_single_line() const -> std::string override {
|
||||||
|
return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
template <> struct adl_serializer<repertory::service_stop_end> {
|
||||||
|
static void to_json(json &data, const repertory::service_stop_end &value) {
|
||||||
|
data["function_name"] = value.function_name;
|
||||||
|
data["service_name"] = value.service_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void from_json(const json &data, repertory::service_stop_end &value) {
|
||||||
|
data.at("function_name").get_to<std::string>(value.function_name);
|
||||||
|
data.at("service_name").get_to<std::string>(value.service_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_END_HPP_
|
@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
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_FILE_MANAGER_EVENTS_HPP_
|
|
||||||
#define REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
|
||||||
|
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "types/repertory.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
|
||||||
// clang-format off
|
|
||||||
E_SIMPLE2(download_begin, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(download_end, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING,
|
|
||||||
api_error, result, result, E_FROM_API_FILE_ERROR
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(download_progress, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING,
|
|
||||||
double, progress, prog, E_FROM_DOUBLE_PRECISE
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(download_restored, info,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(download_restore_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(download_resume_add_failed, error,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING,
|
|
||||||
std::string, error, err, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(download_resume_added, debug,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE2(download_resume_removed, debug,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, dest_path, dest, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE1(item_timeout, trace,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING
|
|
||||||
);
|
|
||||||
|
|
||||||
E_SIMPLE3(download_type_selected, debug,
|
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
|
||||||
std::string, source, src, E_FROM_STRING,
|
|
||||||
download_type, download_type, type, E_FROM_DOWNLOAD_TYPE
|
|
||||||
);
|
|
||||||
// clang-format on
|
|
||||||
} // namespace repertory
|
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_
|
|
@ -23,8 +23,8 @@
|
|||||||
#define REPERTORY_INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
#define REPERTORY_INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_
|
||||||
|
|
||||||
#include "db/i_file_mgr_db.hpp"
|
#include "db/i_file_mgr_db.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/file_upload_completed.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "file_manager/i_open_file.hpp"
|
#include "file_manager/i_open_file.hpp"
|
||||||
#include "file_manager/i_upload_manager.hpp"
|
#include "file_manager/i_upload_manager.hpp"
|
||||||
@ -37,7 +37,7 @@ class app_config;
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
|
|
||||||
class file_manager final : public i_file_manager, public i_upload_manager {
|
class file_manager final : public i_file_manager, public i_upload_manager {
|
||||||
E_CONSUMER();
|
E_CONSUMER2();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr const std::chrono::seconds queue_wait_secs{
|
static constexpr const std::chrono::seconds queue_wait_secs{
|
||||||
|
@ -287,7 +287,9 @@ enum class exit_code : std::int32_t {
|
|||||||
enum http_error_codes : std::int32_t {
|
enum http_error_codes : std::int32_t {
|
||||||
ok = 200,
|
ok = 200,
|
||||||
multiple_choices = 300,
|
multiple_choices = 300,
|
||||||
|
unauthorized = 401,
|
||||||
not_found = 404,
|
not_found = 404,
|
||||||
|
internal_error = 500,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class lock_result {
|
enum class lock_result {
|
||||||
|
@ -21,8 +21,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "comm/packet/client_pool.hpp"
|
#include "comm/packet/client_pool.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
|
||||||
@ -43,7 +46,7 @@ void client_pool::pool::execute(
|
|||||||
client_pool::pool::pool(std::uint8_t pool_size) {
|
client_pool::pool::pool(std::uint8_t pool_size) {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
event_system::instance().raise<service_started>("client_pool");
|
event_system2::instance().raise<service_start_begin>("client_pool");
|
||||||
|
|
||||||
for (std::uint8_t i = 0U; i < pool_size; i++) {
|
for (std::uint8_t i = 0U; i < pool_size; i++) {
|
||||||
pool_queues_.emplace_back(std::make_unique<work_queue>());
|
pool_queues_.emplace_back(std::make_unique<work_queue>());
|
||||||
@ -105,6 +108,8 @@ client_pool::pool::pool(std::uint8_t pool_size) {
|
|||||||
queue_lock.unlock();
|
queue_lock.unlock();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_system2::instance().raise<service_start_end>("client_pool");
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_pool::pool::shutdown() {
|
void client_pool::pool::shutdown() {
|
||||||
@ -150,7 +155,7 @@ void client_pool::shutdown() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_begin>("client_pool");
|
event_system2::instance().raise<service_stop_begin>("client_pool");
|
||||||
unique_mutex_lock pool_lock(pool_mutex_);
|
unique_mutex_lock pool_lock(pool_mutex_);
|
||||||
if (not shutdown_) {
|
if (not shutdown_) {
|
||||||
shutdown_ = true;
|
shutdown_ = true;
|
||||||
@ -160,6 +165,6 @@ void client_pool::shutdown() {
|
|||||||
pool_lookup_.clear();
|
pool_lookup_.clear();
|
||||||
}
|
}
|
||||||
pool_lock.unlock();
|
pool_lock.unlock();
|
||||||
event_system::instance().raise<service_shutdown_end>("client_pool");
|
event_system2::instance().raise<service_stop_end>("client_pool");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "comm/packet/packet_client.hpp"
|
#include "comm/packet/packet_client.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/collection.hpp"
|
#include "utils/collection.hpp"
|
||||||
@ -190,7 +190,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
|||||||
|
|
||||||
timeout request_timeout(
|
timeout request_timeout(
|
||||||
[method, current_client]() {
|
[method, current_client]() {
|
||||||
event_system::instance().raise<packet_client_timeout>(
|
event_system2::instance().raise<packet_client_timeout>(
|
||||||
"request", std::string{method});
|
"request", std::string{method});
|
||||||
packet_client::close(*current_client);
|
packet_client::close(*current_client);
|
||||||
},
|
},
|
||||||
@ -212,7 +212,7 @@ auto packet_client::send(std::string_view method, packet &request,
|
|||||||
|
|
||||||
timeout response_timeout(
|
timeout response_timeout(
|
||||||
[method, current_client]() {
|
[method, current_client]() {
|
||||||
event_system::instance().raise<packet_client_timeout>(
|
event_system2::instance().raise<packet_client_timeout>(
|
||||||
"response", std::string{method});
|
"response", std::string{method});
|
||||||
packet_client::close(*current_client);
|
packet_client::close(*current_client);
|
||||||
},
|
},
|
||||||
|
@ -22,8 +22,11 @@
|
|||||||
#include "comm/packet/packet_server.hpp"
|
#include "comm/packet/packet_server.hpp"
|
||||||
|
|
||||||
#include "comm/packet/packet.hpp"
|
#include "comm/packet/packet.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
@ -37,12 +40,13 @@ packet_server::packet_server(std::uint16_t port, std::string token,
|
|||||||
: encryption_token_(std::move(token)),
|
: encryption_token_(std::move(token)),
|
||||||
closed_(std::move(closed)),
|
closed_(std::move(closed)),
|
||||||
message_handler_(std::move(message_handler)) {
|
message_handler_(std::move(message_handler)) {
|
||||||
|
event_system2::instance().raise<service_start_begin>("packet_server");
|
||||||
initialize(port, pool_size);
|
initialize(port, pool_size);
|
||||||
event_system::instance().raise<service_started>("packet_server");
|
event_system2::instance().raise<service_start_end>("packet_server");
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_server::~packet_server() {
|
packet_server::~packet_server() {
|
||||||
event_system::instance().raise<service_shutdown_begin>("packet_server");
|
event_system2::instance().raise<service_stop_begin>("packet_server");
|
||||||
std::thread([this]() {
|
std::thread([this]() {
|
||||||
for (std::size_t i = 0U; i < service_threads_.size(); i++) {
|
for (std::size_t i = 0U; i < service_threads_.size(); i++) {
|
||||||
io_context_.stop();
|
io_context_.stop();
|
||||||
@ -51,7 +55,7 @@ packet_server::~packet_server() {
|
|||||||
|
|
||||||
server_thread_->join();
|
server_thread_->join();
|
||||||
server_thread_.reset();
|
server_thread_.reset();
|
||||||
event_system::instance().raise<service_shutdown_end>("packet_server");
|
event_system2::instance().raise<service_stop_end>("packet_server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet_server::add_client(connection &conn, const std::string &client_id) {
|
void packet_server::add_client(connection &conn, const std::string &client_id) {
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include "drives/fuse/fuse_base.hpp"
|
#include "drives/fuse/fuse_base.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "drives/fuse/events.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "initialize.hpp"
|
#include "initialize.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "utils/collection.hpp"
|
#include "utils/collection.hpp"
|
||||||
@ -90,12 +88,12 @@ fuse_base::fuse_base(app_config &config) : config_(config) {
|
|||||||
fuse_ops_.flag_reserved = 0;
|
fuse_ops_.flag_reserved = 0;
|
||||||
#endif // FUSE_USE_VERSION < 30
|
#endif // FUSE_USE_VERSION < 30
|
||||||
|
|
||||||
E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) {
|
E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) {
|
||||||
std::thread([this]() { this->shutdown(); }).detach();
|
std::thread([this]() { this->shutdown(); }).detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fuse_base::~fuse_base() { E_CONSUMER_RELEASE(); }
|
fuse_base::~fuse_base() { E_CONSUMER2_RELEASE(); }
|
||||||
|
|
||||||
auto fuse_base::access_(const char *path, int mask) -> int {
|
auto fuse_base::access_(const char *path, int mask) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
@ -372,13 +370,13 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
|
|||||||
if (not utils::file::change_to_process_directory()) {
|
if (not utils::file::change_to_process_directory()) {
|
||||||
utils::error::raise_error(function_name,
|
utils::error::raise_error(function_name,
|
||||||
"failed to change to process directory");
|
"failed to change to process directory");
|
||||||
event_system::instance().raise<unmount_requested>();
|
event_system2::instance().raise<unmount_requested>();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not console_enabled_ && not repertory::project_initialize()) {
|
if (not console_enabled_ && not repertory::project_initialize()) {
|
||||||
utils::error::raise_error(function_name, "failed to initialize repertory");
|
utils::error::raise_error(function_name, "failed to initialize repertory");
|
||||||
event_system::instance().raise<unmount_requested>();
|
event_system2::instance().raise<unmount_requested>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@ -601,7 +599,7 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fuse_base::notify_fuse_args_parsed(const std::vector<std::string> &args) {
|
void fuse_base::notify_fuse_args_parsed(const std::vector<std::string> &args) {
|
||||||
event_system::instance().raise<fuse_args_parsed>(std::accumulate(
|
event_system2::instance().raise<fuse_args_parsed>(std::accumulate(
|
||||||
args.begin(), args.end(), std::string(),
|
args.begin(), args.end(), std::string(),
|
||||||
[](auto &&command_line, auto &&arg) -> auto {
|
[](auto &&command_line, auto &&arg) -> auto {
|
||||||
command_line += (command_line.empty() ? arg : (" " + std::string(arg)));
|
command_line += (command_line.empty() ? arg : (" " + std::string(arg)));
|
||||||
@ -700,7 +698,7 @@ void fuse_base::raise_fuse_event(std::string_view function_name,
|
|||||||
if (((config_.get_event_level() >= fuse_event::level) && (ret != 0)) ||
|
if (((config_.get_event_level() >= fuse_event::level) && (ret != 0)) ||
|
||||||
(config_.get_event_level() >= event_level::trace)) {
|
(config_.get_event_level() >= event_level::trace)) {
|
||||||
std::string func{function_name};
|
std::string func{function_name};
|
||||||
event_system::instance().raise<fuse_event>(
|
event_system2::instance().raise<fuse_event>(
|
||||||
utils::string::right_trim(func, '_'), std::string{api_path}, ret);
|
utils::string::right_trim(func, '_'), std::string{api_path}, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -751,8 +749,8 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
|
|||||||
|
|
||||||
void fuse_base::shutdown() {
|
void fuse_base::shutdown() {
|
||||||
const auto res = unmount(get_mount_location());
|
const auto res = unmount(get_mount_location());
|
||||||
event_system::instance().raise<unmount_result>(get_mount_location(),
|
event_system2::instance().raise<unmount_result>(get_mount_location(),
|
||||||
std::to_string(res));
|
std::to_string(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
@ -30,9 +30,7 @@
|
|||||||
#include "drives/fuse/remotefuse/remote_server.hpp"
|
#include "drives/fuse/remotefuse/remote_server.hpp"
|
||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/consumers/logging_consumer.hpp"
|
#include "events/consumers/logging_consumer.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/drive_mount_result.hpp"
|
#include "events/types/drive_mount_result.hpp"
|
||||||
#include "events/types/drive_mounted.hpp"
|
#include "events/types/drive_mounted.hpp"
|
||||||
#include "events/types/drive_unmount_pending.hpp"
|
#include "events/types/drive_unmount_pending.hpp"
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include "drives/fuse/fuse_drive_base.hpp"
|
#include "drives/fuse/fuse_drive_base.hpp"
|
||||||
|
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "utils/common.hpp"
|
#include "utils/common.hpp"
|
||||||
@ -34,8 +33,8 @@ auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error {
|
|||||||
return check_access(api_path, mask);
|
return check_access(api_path, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive_base::check_access(const std::string &api_path,
|
auto fuse_drive_base::check_access(const std::string &api_path, int mask) const
|
||||||
int mask) const -> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
api_meta_map meta;
|
api_meta_map meta;
|
||||||
@ -136,8 +135,9 @@ auto fuse_drive_base::check_and_perform(
|
|||||||
return action(meta);
|
return action(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive_base::check_open_flags(
|
auto fuse_drive_base::check_open_flags(int flags, int mask,
|
||||||
int flags, int mask, const api_error &fail_error) -> api_error {
|
const api_error &fail_error)
|
||||||
|
-> api_error {
|
||||||
return (((flags & mask) == 0) ? api_error::success : fail_error);
|
return (((flags & mask) == 0) ? api_error::success : fail_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +194,8 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive_base::check_readable(int flags,
|
auto fuse_drive_base::check_readable(int flags, const api_error &fail_error)
|
||||||
const api_error &fail_error) -> api_error {
|
-> api_error {
|
||||||
auto mode = (flags & O_ACCMODE);
|
auto mode = (flags & O_ACCMODE);
|
||||||
return ((mode == O_WRONLY) ? fail_error : api_error::success);
|
return ((mode == O_WRONLY) ? fail_error : api_error::success);
|
||||||
}
|
}
|
||||||
@ -253,13 +253,16 @@ auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
auto fuse_drive_base::parse_xattr_parameters(
|
auto fuse_drive_base::parse_xattr_parameters(const char *name,
|
||||||
const char *name, const uint32_t &position, std::string &attribute_name,
|
const uint32_t &position,
|
||||||
const std::string &api_path) -> api_error {
|
std::string &attribute_name,
|
||||||
|
const std::string &api_path)
|
||||||
|
-> api_error {
|
||||||
#else // !defined(__APPLE__)
|
#else // !defined(__APPLE__)
|
||||||
auto fuse_drive_base::parse_xattr_parameters(
|
auto fuse_drive_base::parse_xattr_parameters(const char *name,
|
||||||
const char *name, std::string &attribute_name,
|
std::string &attribute_name,
|
||||||
const std::string &api_path) -> api_error {
|
const std::string &api_path)
|
||||||
|
-> api_error {
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
auto res = api_path.empty() ? api_error::bad_address : api_error::success;
|
auto res = api_path.empty() ? api_error::bad_address : api_error::success;
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -292,9 +295,11 @@ auto fuse_drive_base::parse_xattr_parameters(
|
|||||||
std::string &attribute_name, const std::string &api_path) -> api_error {
|
std::string &attribute_name, const std::string &api_path) -> api_error {
|
||||||
auto res = parse_xattr_parameters(name, position, attribute_name, api_path);
|
auto res = parse_xattr_parameters(name, position, attribute_name, api_path);
|
||||||
#else // !defined(__APPLE__)
|
#else // !defined(__APPLE__)
|
||||||
auto fuse_drive_base::parse_xattr_parameters(
|
auto fuse_drive_base::parse_xattr_parameters(const char *name,
|
||||||
const char *name, const char *value, size_t size,
|
const char *value, size_t size,
|
||||||
std::string &attribute_name, const std::string &api_path) -> api_error {
|
std::string &attribute_name,
|
||||||
|
const std::string &api_path)
|
||||||
|
-> api_error {
|
||||||
auto res = parse_xattr_parameters(name, attribute_name, api_path);
|
auto res = parse_xattr_parameters(name, attribute_name, api_path);
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
|
@ -24,12 +24,9 @@
|
|||||||
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
|
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "drives/fuse/events.hpp"
|
|
||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/consumers/logging_consumer.hpp"
|
#include "events/consumers/logging_consumer.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/drive_mount_result.hpp"
|
#include "events/types/drive_mount_result.hpp"
|
||||||
#include "events/types/drive_mounted.hpp"
|
#include "events/types/drive_mounted.hpp"
|
||||||
#include "events/types/drive_unmount_pending.hpp"
|
#include "events/types/drive_unmount_pending.hpp"
|
||||||
@ -262,7 +259,7 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
|
|||||||
if (remote_instance_->fuse_init() != 0) {
|
if (remote_instance_->fuse_init() != 0) {
|
||||||
utils::error::raise_error(function_name,
|
utils::error::raise_error(function_name,
|
||||||
"failed to connect to remote server");
|
"failed to connect to remote server");
|
||||||
event_system::instance().raise<unmount_requested>();
|
event_system2::instance().raise<unmount_requested>();
|
||||||
} else {
|
} else {
|
||||||
server_ = std::make_shared<server>(config_);
|
server_ = std::make_shared<server>(config_);
|
||||||
server_->start();
|
server_->start();
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "comm/packet/packet.hpp"
|
#include "comm/packet/packet.hpp"
|
||||||
#include "drives/directory_iterator.hpp"
|
#include "drives/directory_iterator.hpp"
|
||||||
#include "drives/remote/remote_open_file_table.hpp"
|
#include "drives/remote/remote_open_file_table.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "types/remote.hpp"
|
#include "types/remote.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
@ -43,7 +43,7 @@ namespace repertory::remote_fuse {
|
|||||||
(((config_.get_event_level() >= remote_fuse_server_event::level) && \
|
(((config_.get_event_level() >= remote_fuse_server_event::level) && \
|
||||||
((ret) < 0)) || \
|
((ret) < 0)) || \
|
||||||
(config_.get_event_level() >= event_level::trace))) \
|
(config_.get_event_level() >= event_level::trace))) \
|
||||||
event_system::instance().raise<remote_fuse_server_event>(std::string{func}, \
|
event_system2::instance().raise<remote_fuse_server_event>(std::string{func}, \
|
||||||
file, ret)
|
file, ret)
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "drives/remote/remote_open_file_table.hpp"
|
#include "drives/remote/remote_open_file_table.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "utils/collection.hpp"
|
#include "utils/collection.hpp"
|
||||||
#include "utils/config.hpp"
|
#include "utils/config.hpp"
|
||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/drive_mounted.hpp"
|
#include "events/types/drive_mounted.hpp"
|
||||||
#include "events/types/drive_unmount_pending.hpp"
|
#include "events/types/drive_unmount_pending.hpp"
|
||||||
#include "events/types/drive_unmounted.hpp"
|
#include "events/types/drive_unmounted.hpp"
|
||||||
@ -38,7 +37,7 @@ namespace repertory::remote_winfsp {
|
|||||||
(((config_.get_event_level() >= remote_winfsp_client_event::level) && \
|
(((config_.get_event_level() >= remote_winfsp_client_event::level) && \
|
||||||
((ret) != STATUS_SUCCESS)) || \
|
((ret) != STATUS_SUCCESS)) || \
|
||||||
(config_.get_event_level() >= event_level::trace))) \
|
(config_.get_event_level() >= event_level::trace))) \
|
||||||
event_system::instance().raise<remote_winfsp_client_event>( \
|
event_system2::instance().raise<remote_winfsp_client_event>( \
|
||||||
std::string{func}, file, ret)
|
std::string{func}, file, ret)
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
||||||
#include "drives/remote/remote_open_file_table.hpp"
|
#include "drives/remote/remote_open_file_table.hpp"
|
||||||
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
#include "drives/winfsp/remotewinfsp/i_remote_instance.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "types/remote.hpp"
|
#include "types/remote.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
@ -49,7 +48,7 @@ namespace repertory::remote_winfsp {
|
|||||||
(((config_.get_event_level() >= remote_winfsp_server_event::level) && \
|
(((config_.get_event_level() >= remote_winfsp_server_event::level) && \
|
||||||
((ret) != STATUS_SUCCESS)) || \
|
((ret) != STATUS_SUCCESS)) || \
|
||||||
(config_.get_event_level() >= event_level::trace))) \
|
(config_.get_event_level() >= event_level::trace))) \
|
||||||
event_system::instance().raise<remote_winfsp_server_event>( \
|
event_system2::instance().raise<remote_winfsp_server_event>( \
|
||||||
std::string{func}, file, ret)
|
std::string{func}, file, ret)
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/consumers/logging_consumer.hpp"
|
#include "events/consumers/logging_consumer.hpp"
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/drive_mount_failed.hpp"
|
#include "events/types/drive_mount_failed.hpp"
|
||||||
#include "events/types/drive_mount_result.hpp"
|
#include "events/types/drive_mount_result.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
@ -105,7 +104,7 @@ remote_winfsp_drive::remote_winfsp_drive(app_config &config,
|
|||||||
config_(config),
|
config_(config),
|
||||||
lock_(lock),
|
lock_(lock),
|
||||||
factory_(std::move(factory)) {
|
factory_(std::move(factory)) {
|
||||||
E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) {
|
E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) {
|
||||||
std::thread([this]() { this->shutdown(); }).detach();
|
std::thread([this]() { this->shutdown(); }).detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/consumers/logging_consumer.hpp"
|
#include "events/consumers/logging_consumer.hpp"
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/drive_mount_failed.hpp"
|
#include "events/types/drive_mount_failed.hpp"
|
||||||
#include "events/types/drive_mount_result.hpp"
|
#include "events/types/drive_mount_result.hpp"
|
||||||
#include "events/types/drive_mounted.hpp"
|
#include "events/types/drive_mounted.hpp"
|
||||||
@ -66,7 +65,7 @@ E_SIMPLE(drive_stop_timed_out, info);
|
|||||||
(((config_.get_event_level() >= winfsp_event::level) && \
|
(((config_.get_event_level() >= winfsp_event::level) && \
|
||||||
(ret != STATUS_SUCCESS)) || \
|
(ret != STATUS_SUCCESS)) || \
|
||||||
(config_.get_event_level() >= event_level::trace))) \
|
(config_.get_event_level() >= event_level::trace))) \
|
||||||
event_system::instance().raise<winfsp_event>(std::string{func}, file, ret)
|
event_system2::instance().raise<winfsp_event>(std::string{func}, file, ret)
|
||||||
|
|
||||||
winfsp_drive::winfsp_service::winfsp_service(
|
winfsp_drive::winfsp_service::winfsp_service(
|
||||||
lock_data &lock, winfsp_drive &drive, std::vector<std::string> drive_args,
|
lock_data &lock, winfsp_drive &drive, std::vector<std::string> drive_args,
|
||||||
@ -146,11 +145,11 @@ auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/)
|
|||||||
auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
event_system::instance().raise<drive_stop_begin>();
|
event_system2::instance().raise<drive_stop_begin>();
|
||||||
|
|
||||||
timeout stop_timeout(
|
timeout stop_timeout(
|
||||||
[]() {
|
[]() {
|
||||||
event_system::instance().raise<drive_stop_timed_out>();
|
event_system2::instance().raise<drive_stop_timed_out>();
|
||||||
app_config::set_stop_requested();
|
app_config::set_stop_requested();
|
||||||
},
|
},
|
||||||
30s);
|
30s);
|
||||||
@ -158,7 +157,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
|||||||
|
|
||||||
stop_timeout.disable();
|
stop_timeout.disable();
|
||||||
|
|
||||||
event_system::instance().raise<drive_stop_end>();
|
event_system2::instance().raise<drive_stop_end>();
|
||||||
|
|
||||||
if (not lock_.set_mount_state(false, "", -1)) {
|
if (not lock_.set_mount_state(false, "", -1)) {
|
||||||
utils::error::raise_error(function_name, "failed to set mount state");
|
utils::error::raise_error(function_name, "failed to set mount state");
|
||||||
@ -170,7 +169,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
|||||||
winfsp_drive::winfsp_drive(app_config &config, lock_data &lock,
|
winfsp_drive::winfsp_drive(app_config &config, lock_data &lock,
|
||||||
i_provider &provider)
|
i_provider &provider)
|
||||||
: provider_(provider), config_(config), lock_(lock) {
|
: provider_(provider), config_(config), lock_(lock) {
|
||||||
E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) {
|
E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) {
|
||||||
std::thread([this]() { this->shutdown(); }).detach();
|
std::thread([this]() { this->shutdown(); }).detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -62,40 +62,12 @@ console_consumer::console_consumer(event_level level) {
|
|||||||
|
|
||||||
set_level(level);
|
set_level(level);
|
||||||
|
|
||||||
E_SUBSCRIBE_ALL(process_event);
|
|
||||||
E_SUBSCRIBE2_ALL(process_event2);
|
E_SUBSCRIBE2_ALL(process_event2);
|
||||||
E_SUBSCRIBE2_EXACT(event_level_changed,
|
E_SUBSCRIBE2_EXACT(event_level_changed,
|
||||||
[](auto &&event) { set_level(event.level); });
|
[](auto &&event) { set_level(event.level); });
|
||||||
}
|
}
|
||||||
|
|
||||||
console_consumer::~console_consumer() {
|
console_consumer::~console_consumer() { E_CONSUMER2_RELEASE(); }
|
||||||
E_CONSUMER_RELEASE();
|
|
||||||
E_CONSUMER2_RELEASE();
|
|
||||||
}
|
|
||||||
|
|
||||||
void console_consumer::process_event(const event &evt) {
|
|
||||||
switch (evt.get_event_level()) {
|
|
||||||
case event_level::critical:
|
|
||||||
spdlog::get("console")->critical(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::error:
|
|
||||||
spdlog::get("console")->error(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::warn:
|
|
||||||
spdlog::get("console")->warn(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::info:
|
|
||||||
spdlog::get("console")->info(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::debug:
|
|
||||||
spdlog::get("console")->debug(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::trace:
|
|
||||||
default:
|
|
||||||
spdlog::get("console")->trace(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void console_consumer::process_event2(const i_event &evt) {
|
void console_consumer::process_event2(const i_event &evt) {
|
||||||
switch (evt.get_event_level()) {
|
switch (evt.get_event_level()) {
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "events/consumers/logging_consumer.hpp"
|
#include "events/consumers/logging_consumer.hpp"
|
||||||
|
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/i_event.hpp"
|
#include "events/i_event.hpp"
|
||||||
#include "events/types/event_level_changed.hpp"
|
#include "events/types/event_level_changed.hpp"
|
||||||
#include "spdlog/async.h"
|
#include "spdlog/async.h"
|
||||||
@ -67,40 +66,12 @@ logging_consumer::logging_consumer(event_level level,
|
|||||||
|
|
||||||
set_level(level);
|
set_level(level);
|
||||||
|
|
||||||
E_SUBSCRIBE_ALL(process_event);
|
|
||||||
E_SUBSCRIBE2_ALL(process_event2);
|
E_SUBSCRIBE2_ALL(process_event2);
|
||||||
E_SUBSCRIBE2_EXACT(event_level_changed,
|
E_SUBSCRIBE2_EXACT(event_level_changed,
|
||||||
[](auto &&event) { set_level(event.level); });
|
[](auto &&event) { set_level(event.level); });
|
||||||
}
|
}
|
||||||
|
|
||||||
logging_consumer::~logging_consumer() {
|
logging_consumer::~logging_consumer() { E_CONSUMER2_RELEASE(); }
|
||||||
E_CONSUMER_RELEASE();
|
|
||||||
E_CONSUMER2_RELEASE();
|
|
||||||
}
|
|
||||||
|
|
||||||
void logging_consumer::process_event(const event &evt) {
|
|
||||||
switch (evt.get_event_level()) {
|
|
||||||
case event_level::critical:
|
|
||||||
spdlog::get("file")->critical(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::error:
|
|
||||||
spdlog::get("file")->error(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::warn:
|
|
||||||
spdlog::get("file")->warn(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::info:
|
|
||||||
spdlog::get("file")->info(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::debug:
|
|
||||||
spdlog::get("file")->debug(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
case event_level::trace:
|
|
||||||
default:
|
|
||||||
spdlog::get("file")->trace(evt.get_single_line());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void logging_consumer::process_event2(const i_event &evt) {
|
void logging_consumer::process_event2(const i_event &evt) {
|
||||||
switch (evt.get_event_level()) {
|
switch (evt.get_event_level()) {
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
#include "events/t_event_system.hpp"
|
|
||||||
|
|
||||||
#include "events/event.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
|
||||||
template <typename event_type>
|
|
||||||
auto t_event_system<event_type>::instance() -> t_event_system<event_type> & {
|
|
||||||
return event_system_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename event_type>
|
|
||||||
t_event_system<event_type> t_event_system<event_type>::event_system_;
|
|
||||||
|
|
||||||
template class t_event_system<event>;
|
|
||||||
} // namespace repertory
|
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event.hpp"
|
#include "events/event.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "types/startup_exception.hpp"
|
#include "types/startup_exception.hpp"
|
||||||
#include "utils/file_utils.hpp"
|
#include "utils/file_utils.hpp"
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ auto cache_size_mgr::expand(std::uint64_t size) -> api_error {
|
|||||||
while (not get_stop_requested() && cache_size_ > max_cache_size &&
|
while (not get_stop_requested() && cache_size_ > max_cache_size &&
|
||||||
cache_dir.count() > 1U) {
|
cache_dir.count() > 1U) {
|
||||||
if (last_cache_size != cache_size_) {
|
if (last_cache_size != cache_size_) {
|
||||||
event_system::instance().raise<max_cache_size_reached>(cache_size_,
|
event_system2::instance().raise<max_cache_size_reached>(cache_size_,
|
||||||
max_cache_size);
|
max_cache_size);
|
||||||
last_cache_size = cache_size_;
|
last_cache_size = cache_size_;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ auto cache_size_mgr::shrink(std::uint64_t size) -> api_error {
|
|||||||
if (cache_size_ >= size) {
|
if (cache_size_ >= size) {
|
||||||
cache_size_ -= size;
|
cache_size_ -= size;
|
||||||
} else {
|
} else {
|
||||||
event_system::instance().raise<invalid_cache_size>(cache_size_, size);
|
event_system2::instance().raise<invalid_cache_size>(cache_size_, size);
|
||||||
cache_size_ = 0U;
|
cache_size_ = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,18 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "db/file_mgr_db.hpp"
|
#include "db/file_mgr_db.hpp"
|
||||||
|
#include "events/types/file_upload_failed.hpp"
|
||||||
|
#include "events/types/file_upload_not_found.hpp"
|
||||||
|
#include "events/types/file_upload_queued.hpp"
|
||||||
|
#include "events/types/file_upload_removed.hpp"
|
||||||
|
#include "events/types/file_upload_retry.hpp"
|
||||||
|
#include "events/types/filesystem_item_evicted.hpp"
|
||||||
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "file_manager/cache_size_mgr.hpp"
|
#include "file_manager/cache_size_mgr.hpp"
|
||||||
#include "file_manager/direct_open_file.hpp"
|
#include "file_manager/direct_open_file.hpp"
|
||||||
#include "file_manager/events.hpp"
|
|
||||||
#include "file_manager/open_file.hpp"
|
#include "file_manager/open_file.hpp"
|
||||||
#include "file_manager/open_file_base.hpp"
|
#include "file_manager/open_file_base.hpp"
|
||||||
#include "file_manager/ring_buffer_open_file.hpp"
|
#include "file_manager/ring_buffer_open_file.hpp"
|
||||||
@ -49,17 +58,15 @@ file_manager::file_manager(app_config &config, i_provider &provider)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
E_SUBSCRIBE_EXACT(file_upload_completed,
|
E_SUBSCRIBE2_EXACT(file_upload_completed,
|
||||||
[this](const file_upload_completed &completed) {
|
[this](auto &&event) { this->upload_completed(event); });
|
||||||
this->upload_completed(completed);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file_manager::~file_manager() {
|
file_manager::~file_manager() {
|
||||||
stop();
|
stop();
|
||||||
mgr_db_.reset();
|
mgr_db_.reset();
|
||||||
|
|
||||||
E_CONSUMER_RELEASE();
|
E_CONSUMER2_RELEASE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::close(std::uint64_t handle) {
|
void file_manager::close(std::uint64_t handle) {
|
||||||
@ -111,7 +118,7 @@ void file_manager::close_timed_out_files() {
|
|||||||
|
|
||||||
for (auto &closeable_file : closeable_list) {
|
for (auto &closeable_file : closeable_list) {
|
||||||
closeable_file->close();
|
closeable_file->close();
|
||||||
event_system::instance().raise<item_timeout>(
|
event_system2::instance().raise<item_timeout>(
|
||||||
closeable_file->get_api_path());
|
closeable_file->get_api_path());
|
||||||
}
|
}
|
||||||
closeable_list.clear();
|
closeable_list.clear();
|
||||||
@ -187,8 +194,8 @@ auto file_manager::evict_file(const std::string &api_path) -> bool {
|
|||||||
auto removed = remove_source_and_shrink_cache(api_path, fsi.source_path,
|
auto removed = remove_source_and_shrink_cache(api_path, fsi.source_path,
|
||||||
fsi.size, allocated);
|
fsi.size, allocated);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
event_system::instance().raise<filesystem_item_evicted>(api_path,
|
event_system2::instance().raise<filesystem_item_evicted>(
|
||||||
fsi.source_path);
|
api_path, function_name, fsi.source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
@ -490,7 +497,7 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
|||||||
? download_type::ring_buffer
|
? download_type::ring_buffer
|
||||||
: preferred_type);
|
: preferred_type);
|
||||||
if (not directory) {
|
if (not directory) {
|
||||||
event_system::instance().raise<download_type_selected>(
|
event_system2::instance().raise<download_type_selected>(
|
||||||
fsi.api_path, fsi.source_path, type);
|
fsi.api_path, fsi.source_path, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,6 +531,8 @@ void file_manager::queue_upload(const i_open_file &file) {
|
|||||||
|
|
||||||
void file_manager::queue_upload(const std::string &api_path,
|
void file_manager::queue_upload(const std::string &api_path,
|
||||||
const std::string &source_path, bool no_lock) {
|
const std::string &source_path, bool no_lock) {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (provider_.is_read_only()) {
|
if (provider_.is_read_only()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -540,10 +549,11 @@ void file_manager::queue_upload(const std::string &api_path,
|
|||||||
source_path,
|
source_path,
|
||||||
})) {
|
})) {
|
||||||
remove_resume(api_path, source_path, true);
|
remove_resume(api_path, source_path, true);
|
||||||
event_system::instance().raise<file_upload_queued>(api_path, source_path);
|
event_system2::instance().raise<file_upload_queued>(api_path, function_name,
|
||||||
|
source_path);
|
||||||
} else {
|
} else {
|
||||||
event_system::instance().raise<file_upload_failed>(
|
event_system2::instance().raise<file_upload_failed>(
|
||||||
api_path, source_path, "failed to queue upload");
|
api_path, "failed to queue upload", function_name, source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not no_lock) {
|
if (not no_lock) {
|
||||||
@ -597,8 +607,8 @@ void file_manager::remove_resume(const std::string &api_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mgr_db_->remove_resume(api_path)) {
|
if (mgr_db_->remove_resume(api_path)) {
|
||||||
event_system::instance().raise<download_resume_removed>(api_path,
|
event_system2::instance().raise<download_resume_removed>(api_path,
|
||||||
source_path);
|
source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not no_lock) {
|
if (not no_lock) {
|
||||||
@ -674,7 +684,8 @@ void file_manager::remove_upload(const std::string &api_path, bool no_lock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
event_system::instance().raise<file_upload_removed>(api_path);
|
event_system2::instance().raise<file_upload_removed>(api_path,
|
||||||
|
function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not no_lock) {
|
if (not no_lock) {
|
||||||
@ -838,6 +849,7 @@ void file_manager::start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_system2::instance().raise<service_start_begin>("file_manager");
|
||||||
stop_requested_ = false;
|
stop_requested_ = false;
|
||||||
|
|
||||||
polling::instance().set_callback({
|
polling::instance().set_callback({
|
||||||
@ -848,6 +860,7 @@ void file_manager::start() {
|
|||||||
|
|
||||||
if (provider_.is_read_only()) {
|
if (provider_.is_read_only()) {
|
||||||
stop_requested_ = false;
|
stop_requested_ = false;
|
||||||
|
event_system2::instance().raise<service_start_end>("file_manager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,14 +873,14 @@ void file_manager::start() {
|
|||||||
filesystem_item fsi{};
|
filesystem_item fsi{};
|
||||||
auto res = provider_.get_filesystem_item(entry.api_path, false, fsi);
|
auto res = provider_.get_filesystem_item(entry.api_path, false, fsi);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
event_system::instance().raise<download_restore_failed>(
|
event_system2::instance().raise<download_restore_failed>(
|
||||||
entry.api_path, entry.source_path,
|
entry.api_path, entry.source_path,
|
||||||
"failed to get filesystem item|" + api_error_to_string(res));
|
"failed to get filesystem item|" + api_error_to_string(res));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.source_path != fsi.source_path) {
|
if (entry.source_path != fsi.source_path) {
|
||||||
event_system::instance().raise<download_restore_failed>(
|
event_system2::instance().raise<download_restore_failed>(
|
||||||
fsi.api_path, fsi.source_path,
|
fsi.api_path, fsi.source_path,
|
||||||
"source path mismatch|expected|" + entry.source_path + "|actual|" +
|
"source path mismatch|expected|" + entry.source_path + "|actual|" +
|
||||||
fsi.source_path);
|
fsi.source_path);
|
||||||
@ -876,7 +889,7 @@ void file_manager::start() {
|
|||||||
|
|
||||||
auto opt_size = utils::file::file{fsi.source_path}.size();
|
auto opt_size = utils::file::file{fsi.source_path}.size();
|
||||||
if (not opt_size.has_value()) {
|
if (not opt_size.has_value()) {
|
||||||
event_system::instance().raise<download_restore_failed>(
|
event_system2::instance().raise<download_restore_failed>(
|
||||||
fsi.api_path, fsi.source_path,
|
fsi.api_path, fsi.source_path,
|
||||||
"failed to get file size: " +
|
"failed to get file size: " +
|
||||||
std::to_string(utils::get_last_error_code()));
|
std::to_string(utils::get_last_error_code()));
|
||||||
@ -885,7 +898,7 @@ void file_manager::start() {
|
|||||||
|
|
||||||
auto file_size{opt_size.value()};
|
auto file_size{opt_size.value()};
|
||||||
if (file_size != fsi.size) {
|
if (file_size != fsi.size) {
|
||||||
event_system::instance().raise<download_restore_failed>(
|
event_system2::instance().raise<download_restore_failed>(
|
||||||
fsi.api_path, fsi.source_path,
|
fsi.api_path, fsi.source_path,
|
||||||
"file size mismatch|expected|" + std::to_string(fsi.size) +
|
"file size mismatch|expected|" + std::to_string(fsi.size) +
|
||||||
"|actual|" + std::to_string(file_size));
|
"|actual|" + std::to_string(file_size));
|
||||||
@ -899,15 +912,15 @@ void file_manager::start() {
|
|||||||
: 0U,
|
: 0U,
|
||||||
fsi, provider_, entry.read_state, *this);
|
fsi, provider_, entry.read_state, *this);
|
||||||
open_file_lookup_[entry.api_path] = closeable_file;
|
open_file_lookup_[entry.api_path] = closeable_file;
|
||||||
event_system::instance().raise<download_restored>(fsi.api_path,
|
event_system2::instance().raise<download_restored>(fsi.api_path,
|
||||||
fsi.source_path);
|
fsi.source_path);
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
utils::error::raise_error(function_name, ex, "query error");
|
utils::error::raise_error(function_name, ex, "query error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_thread_ = std::make_unique<std::thread>([this] { upload_handler(); });
|
upload_thread_ = std::make_unique<std::thread>([this] { upload_handler(); });
|
||||||
event_system::instance().raise<service_started>("file_manager");
|
event_system2::instance().raise<service_start_end>("file_manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::stop() {
|
void file_manager::stop() {
|
||||||
@ -915,7 +928,7 @@ void file_manager::stop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_begin>("file_manager");
|
event_system2::instance().raise<service_stop_begin>("file_manager");
|
||||||
|
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
@ -949,7 +962,7 @@ void file_manager::stop() {
|
|||||||
|
|
||||||
upload_thread_.reset();
|
upload_thread_.reset();
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_end>("file_manager");
|
event_system2::instance().raise<service_stop_end>("file_manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::store_resume(const i_open_file &file) {
|
void file_manager::store_resume(const i_open_file &file) {
|
||||||
@ -963,12 +976,12 @@ void file_manager::store_resume(const i_open_file &file) {
|
|||||||
file.get_read_state(),
|
file.get_read_state(),
|
||||||
file.get_source_path(),
|
file.get_source_path(),
|
||||||
})) {
|
})) {
|
||||||
event_system::instance().raise<download_resume_added>(
|
event_system2::instance().raise<download_resume_added>(
|
||||||
file.get_api_path(), file.get_source_path());
|
file.get_api_path(), file.get_source_path());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<download_resume_add_failed>(
|
event_system2::instance().raise<download_resume_add_failed>(
|
||||||
file.get_api_path(), file.get_source_path(), "failed to store resume");
|
file.get_api_path(), file.get_source_path(), "failed to store resume");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,31 +1015,28 @@ void file_manager::upload_completed(const file_upload_completed &evt) {
|
|||||||
|
|
||||||
unique_mutex_lock upload_lock(upload_mtx_);
|
unique_mutex_lock upload_lock(upload_mtx_);
|
||||||
|
|
||||||
if (not utils::string::to_bool(evt.get_cancelled().get<std::string>())) {
|
if (not evt.cancelled) {
|
||||||
auto err = api_error_from_string(evt.get_result().get<std::string>());
|
if (evt.error == api_error::success) {
|
||||||
if (err == api_error::success) {
|
if (not mgr_db_->remove_upload_active(evt.api_path)) {
|
||||||
if (not mgr_db_->remove_upload_active(
|
|
||||||
evt.get_api_path().get<std::string>())) {
|
|
||||||
utils::error::raise_api_path_error(
|
utils::error::raise_api_path_error(
|
||||||
function_name, evt.get_api_path().get<std::string>(),
|
function_name, evt.api_path, evt.source_path, evt.error,
|
||||||
evt.get_source().get<std::string>(),
|
|
||||||
"failed to remove from upload_active table");
|
"failed to remove from upload_active table");
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_lookup_.erase(evt.get_api_path());
|
upload_lookup_.erase(evt.api_path);
|
||||||
} else {
|
} else {
|
||||||
bool exists{};
|
bool exists{};
|
||||||
auto res = provider_.is_file(evt.get_api_path(), exists);
|
auto res = provider_.is_file(evt.api_path, exists);
|
||||||
if ((res == api_error::success && not exists) ||
|
if ((res == api_error::success && not exists) ||
|
||||||
not utils::file::file(evt.get_source().get<std::string>()).exists()) {
|
not utils::file::file(evt.source_path).exists()) {
|
||||||
event_system::instance().raise<file_upload_not_found>(
|
event_system2::instance().raise<file_upload_not_found>(
|
||||||
evt.get_api_path(), evt.get_source());
|
evt.api_path, function_name, evt.source_path);
|
||||||
remove_upload(evt.get_api_path(), true);
|
remove_upload(evt.api_path, true);
|
||||||
} else {
|
} else {
|
||||||
event_system::instance().raise<file_upload_retry>(
|
event_system2::instance().raise<file_upload_retry>(
|
||||||
evt.get_api_path(), evt.get_source(), err);
|
evt.api_path, evt.error, function_name, evt.source_path);
|
||||||
|
|
||||||
queue_upload(evt.get_api_path(), evt.get_source(), true);
|
queue_upload(evt.api_path, evt.source_path, true);
|
||||||
upload_notify_.wait_for(upload_lock, queue_wait_secs);
|
upload_notify_.wait_for(upload_lock, queue_wait_secs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1055,8 +1065,8 @@ void file_manager::upload_handler() {
|
|||||||
switch (res) {
|
switch (res) {
|
||||||
case api_error::item_not_found: {
|
case api_error::item_not_found: {
|
||||||
should_wait = false;
|
should_wait = false;
|
||||||
event_system::instance().raise<file_upload_not_found>(
|
event_system2::instance().raise<file_upload_not_found>(
|
||||||
entry->api_path, entry->source_path);
|
entry->api_path, function_name, entry->source_path);
|
||||||
remove_upload(entry->api_path, true);
|
remove_upload(entry->api_path, true);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -1079,8 +1089,8 @@ void file_manager::upload_handler() {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
event_system::instance().raise<file_upload_retry>(
|
event_system2::instance().raise<file_upload_retry>(
|
||||||
entry->api_path, entry->source_path, res);
|
entry->api_path, res, function_name, entry->source_path);
|
||||||
queue_upload(entry->api_path, entry->source_path, true);
|
queue_upload(entry->api_path, entry->source_path, true);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "file_manager/open_file.hpp"
|
#include "file_manager/open_file.hpp"
|
||||||
|
|
||||||
#include "file_manager/cache_size_mgr.hpp"
|
#include "file_manager/cache_size_mgr.hpp"
|
||||||
#include "file_manager/events.hpp"
|
|
||||||
#include "file_manager/file_manager.hpp"
|
#include "file_manager/file_manager.hpp"
|
||||||
#include "file_manager/i_upload_manager.hpp"
|
#include "file_manager/i_upload_manager.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
@ -294,7 +293,7 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
|||||||
auto data_size = (chunk == read_state.size() - 1U) ? get_last_chunk_size()
|
auto data_size = (chunk == read_state.size() - 1U) ? get_last_chunk_size()
|
||||||
: get_chunk_size();
|
: get_chunk_size();
|
||||||
if (get_active_downloads().empty() && (read_state.count() == 0U)) {
|
if (get_active_downloads().empty() && (read_state.count() == 0U)) {
|
||||||
event_system::instance().raise<download_begin>(get_api_path(),
|
event_system2::instance().raise<download_begin>(get_api_path(),
|
||||||
get_source_path());
|
get_source_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,16 +316,16 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
|||||||
auto progress = (static_cast<double>(state.count()) /
|
auto progress = (static_cast<double>(state.count()) /
|
||||||
static_cast<double>(state.size())) *
|
static_cast<double>(state.size())) *
|
||||||
100.0;
|
100.0;
|
||||||
event_system::instance().raise<download_progress>(
|
event_system2::instance().raise<download_progress>(
|
||||||
get_api_path(), get_source_path(), progress);
|
get_api_path(), get_source_path(), progress);
|
||||||
if (state.all() && not notified_) {
|
if (state.all() && not notified_) {
|
||||||
notified_ = true;
|
notified_ = true;
|
||||||
event_system::instance().raise<download_end>(
|
event_system2::instance().raise<download_end>(
|
||||||
get_api_path(), get_source_path(), get_api_error());
|
get_api_path(), get_source_path(), get_api_error());
|
||||||
}
|
}
|
||||||
} else if (not notified_) {
|
} else if (not notified_) {
|
||||||
notified_ = true;
|
notified_ = true;
|
||||||
event_system::instance().raise<download_end>(
|
event_system2::instance().raise<download_end>(
|
||||||
get_api_path(), get_source_path(), get_api_error());
|
get_api_path(), get_source_path(), get_api_error());
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
@ -21,8 +21,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "file_manager/open_file_base.hpp"
|
#include "file_manager/open_file_base.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "file_manager/events.hpp"
|
#include "events/types/filesystem_item_closed.hpp"
|
||||||
|
#include "events/types/filesystem_item_handle_closed.hpp"
|
||||||
|
#include "events/types/filesystem_item_handle_opened.hpp"
|
||||||
|
#include "events/types/filesystem_item_opened.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
|
|
||||||
@ -90,15 +93,17 @@ open_file_base::open_file_base(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void open_file_base::add(std::uint64_t handle, open_file_data ofd) {
|
void open_file_base::add(std::uint64_t handle, open_file_data ofd) {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
recur_mutex_lock file_lock(file_mtx_);
|
recur_mutex_lock file_lock(file_mtx_);
|
||||||
open_data_[handle] = ofd;
|
open_data_[handle] = ofd;
|
||||||
if (open_data_.size() == 1U) {
|
if (open_data_.size() == 1U) {
|
||||||
event_system::instance().raise<filesystem_item_opened>(
|
event_system2::instance().raise<filesystem_item_opened>(
|
||||||
fsi_.api_path, fsi_.source_path, fsi_.directory);
|
fsi_.api_path, fsi_.directory, function_name, fsi_.source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<filesystem_item_handle_opened>(
|
event_system2::instance().raise<filesystem_item_handle_opened>(
|
||||||
fsi_.api_path, handle, fsi_.source_path, fsi_.directory);
|
fsi_.api_path, fsi_.directory, function_name, handle, fsi_.source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto open_file_base::can_close() const -> bool {
|
auto open_file_base::can_close() const -> bool {
|
||||||
@ -309,23 +314,29 @@ void open_file_base::notify_io() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void open_file_base::remove(std::uint64_t handle) {
|
void open_file_base::remove(std::uint64_t handle) {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
recur_mutex_lock file_lock(file_mtx_);
|
recur_mutex_lock file_lock(file_mtx_);
|
||||||
if (open_data_.find(handle) == open_data_.end()) {
|
if (open_data_.find(handle) == open_data_.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
open_data_.erase(handle);
|
open_data_.erase(handle);
|
||||||
event_system::instance().raise<filesystem_item_handle_closed>(
|
event_system2::instance().raise<filesystem_item_handle_closed>(
|
||||||
fsi_.api_path, handle, fsi_.source_path, fsi_.directory, modified_);
|
fsi_.api_path, modified_, fsi_.directory, function_name, handle,
|
||||||
|
fsi_.source_path);
|
||||||
if (not open_data_.empty()) {
|
if (not open_data_.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<filesystem_item_closed>(
|
event_system2::instance().raise<filesystem_item_closed>(
|
||||||
fsi_.api_path, fsi_.source_path, fsi_.directory, modified_);
|
fsi_.api_path, modified_, fsi_.directory, function_name,
|
||||||
|
fsi_.source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_file_base::remove_all() {
|
void open_file_base::remove_all() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
recur_mutex_lock file_lock(file_mtx_);
|
recur_mutex_lock file_lock(file_mtx_);
|
||||||
if (open_data_.empty()) {
|
if (open_data_.empty()) {
|
||||||
return;
|
return;
|
||||||
@ -335,12 +346,14 @@ void open_file_base::remove_all() {
|
|||||||
open_data_.clear();
|
open_data_.clear();
|
||||||
|
|
||||||
for (const auto &data : open_data) {
|
for (const auto &data : open_data) {
|
||||||
event_system::instance().raise<filesystem_item_handle_closed>(
|
event_system2::instance().raise<filesystem_item_handle_closed>(
|
||||||
fsi_.api_path, data.first, fsi_.source_path, fsi_.directory, modified_);
|
fsi_.api_path, modified_, fsi_.directory, function_name, data.first,
|
||||||
|
fsi_.source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<filesystem_item_closed>(
|
event_system2::instance().raise<filesystem_item_closed>(
|
||||||
fsi_.api_path, fsi_.source_path, fsi_.directory, modified_);
|
fsi_.api_path, modified_, fsi_.directory, function_name,
|
||||||
|
fsi_.source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_file_base::reset_timeout() {
|
void open_file_base::reset_timeout() {
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "file_manager/ring_buffer_base.hpp"
|
#include "file_manager/ring_buffer_base.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "file_manager/events.hpp"
|
|
||||||
#include "file_manager/open_file_base.hpp"
|
#include "file_manager/open_file_base.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
@ -65,7 +64,7 @@ auto ring_buffer_base::check_start() -> api_error {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<download_begin>(get_api_path(),
|
event_system2::instance().raise<download_begin>(get_api_path(),
|
||||||
get_source_path());
|
get_source_path());
|
||||||
reader_thread_ =
|
reader_thread_ =
|
||||||
std::make_unique<std::thread>([this]() { reader_thread(); });
|
std::make_unique<std::thread>([this]() { reader_thread(); });
|
||||||
@ -156,7 +155,7 @@ auto ring_buffer_base::download_chunk(std::size_t chunk, bool skip_active)
|
|||||||
auto progress = (static_cast<double>(chunk + 1U) /
|
auto progress = (static_cast<double>(chunk + 1U) /
|
||||||
static_cast<double>(total_chunks_)) *
|
static_cast<double>(total_chunks_)) *
|
||||||
100.0;
|
100.0;
|
||||||
event_system::instance().raise<download_progress>(
|
event_system2::instance().raise<download_progress>(
|
||||||
get_api_path(), get_source_path(), progress);
|
get_api_path(), get_source_path(), progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,7 +291,7 @@ void ring_buffer_base::reader_thread() {
|
|||||||
download_chunk(next_chunk, true);
|
download_chunk(next_chunk, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<download_end>(
|
event_system2::instance().raise<download_end>(
|
||||||
get_api_path(), get_source_path(), api_error::download_stopped);
|
get_api_path(), get_source_path(), api_error::download_stopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "file_manager/upload.hpp"
|
#include "file_manager/upload.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "file_manager/events.hpp"
|
#include "events/types/file_upload_completed.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
@ -60,7 +60,8 @@ void upload::upload_thread() {
|
|||||||
utils::get_last_error_code(), "failed to reset modified time");
|
utils::get_last_error_code(), "failed to reset modified time");
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<file_upload_completed>(
|
event_system2::instance().raise<file_upload_completed>(
|
||||||
get_api_path(), get_source_path(), get_api_error(), cancelled_);
|
get_api_path(), cancelled_, get_api_error(), function_name,
|
||||||
|
get_source_path());
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#include "platform/unix_platform.hpp"
|
#include "platform/unix_platform.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/filesystem_item_added.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "types/startup_exception.hpp"
|
#include "types/startup_exception.hpp"
|
||||||
#include "utils/common.hpp"
|
#include "utils/common.hpp"
|
||||||
@ -225,6 +225,8 @@ auto create_meta_attributes(
|
|||||||
|
|
||||||
auto provider_meta_handler(i_provider &provider, bool directory,
|
auto provider_meta_handler(i_provider &provider, bool directory,
|
||||||
const api_file &file) -> api_error {
|
const api_file &file) -> api_error {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto meta = create_meta_attributes(
|
const auto meta = create_meta_attributes(
|
||||||
file.accessed_date,
|
file.accessed_date,
|
||||||
directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE,
|
directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE,
|
||||||
@ -235,8 +237,8 @@ auto provider_meta_handler(i_provider &provider, bool directory,
|
|||||||
file.modified_date);
|
file.modified_date);
|
||||||
auto res = provider.set_item_meta(file.api_path, meta);
|
auto res = provider.set_item_meta(file.api_path, meta);
|
||||||
if (res == api_error::success) {
|
if (res == api_error::success) {
|
||||||
event_system::instance().raise<filesystem_item_added>(
|
event_system2::instance().raise<filesystem_item_added>(
|
||||||
file.api_path, file.api_parent, directory);
|
file.api_parent, file.api_path, directory, function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
|
|
||||||
#include "platform/win32_platform.hpp"
|
#include "platform/win32_platform.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/filesystem_item_added.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
auto lock_data::get_mount_state(const provider_type & /*pt*/,
|
auto lock_data::get_mount_state(const provider_type & /*pt*/, json &mount_state)
|
||||||
json &mount_state) -> bool {
|
-> bool {
|
||||||
const auto ret = get_mount_state(mount_state);
|
const auto ret = get_mount_state(mount_state);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
const auto mount_id =
|
const auto mount_id =
|
||||||
@ -196,6 +196,8 @@ auto create_meta_attributes(
|
|||||||
|
|
||||||
auto provider_meta_handler(i_provider &provider, bool directory,
|
auto provider_meta_handler(i_provider &provider, bool directory,
|
||||||
const api_file &file) -> api_error {
|
const api_file &file) -> api_error {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto meta = create_meta_attributes(
|
const auto meta = create_meta_attributes(
|
||||||
file.accessed_date,
|
file.accessed_date,
|
||||||
directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE,
|
directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE,
|
||||||
@ -204,8 +206,8 @@ auto provider_meta_handler(i_provider &provider, bool directory,
|
|||||||
file.source_path, 0u, file.modified_date);
|
file.source_path, 0u, file.modified_date);
|
||||||
auto res = provider.set_item_meta(file.api_path, meta);
|
auto res = provider.set_item_meta(file.api_path, meta);
|
||||||
if (res == api_error::success) {
|
if (res == api_error::success) {
|
||||||
event_system::instance().raise<filesystem_item_added>(
|
event_system2::instance().raise<filesystem_item_added>(
|
||||||
file.api_path, file.api_parent, directory);
|
file.api_parent, file.api_path, directory, function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -23,12 +23,20 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "db/meta_db.hpp"
|
#include "db/meta_db.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/directory_remove_failed.hpp"
|
#include "events/types/directory_remove_failed.hpp"
|
||||||
#include "events/types/directory_removed.hpp"
|
#include "events/types/directory_removed.hpp"
|
||||||
#include "events/types/directory_removed_externally.hpp"
|
#include "events/types/directory_removed_externally.hpp"
|
||||||
|
#include "events/types/file_remove_failed.hpp"
|
||||||
|
#include "events/types/file_removed.hpp"
|
||||||
|
#include "events/types/file_removed_externally.hpp"
|
||||||
|
#include "events/types/orphaned_file_detected.hpp"
|
||||||
|
#include "events/types/orphaned_file_processing_failed.hpp"
|
||||||
|
#include "events/types/orphaned_source_file_detected.hpp"
|
||||||
|
#include "events/types/orphaned_source_file_removed.hpp"
|
||||||
|
#include "events/types/provider_offline.hpp"
|
||||||
|
#include "events/types/provider_upload_begin.hpp"
|
||||||
|
#include "events/types/provider_upload_end.hpp"
|
||||||
#include "file_manager/cache_size_mgr.hpp"
|
#include "file_manager/cache_size_mgr.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
@ -504,32 +512,35 @@ void base_provider::process_removed_files(std::deque<removed_item> removed_list,
|
|||||||
orphaned_directory, {utils::path::strip_to_file_name(item.source_path) +
|
orphaned_directory, {utils::path::strip_to_file_name(item.source_path) +
|
||||||
'_' + parts[parts.size() - 1U]});
|
'_' + parts[parts.size() - 1U]});
|
||||||
|
|
||||||
event_system::instance().raise<orphaned_file_detected>(item.source_path);
|
event_system2::instance().raise<orphaned_file_detected>(function_name,
|
||||||
|
item.source_path);
|
||||||
if (not utils::file::reset_modified_time(item.source_path)) {
|
if (not utils::file::reset_modified_time(item.source_path)) {
|
||||||
event_system::instance().raise<orphaned_file_processing_failed>(
|
event_system2::instance().raise<orphaned_file_processing_failed>(
|
||||||
item.source_path, orphaned_file,
|
orphaned_file,
|
||||||
"reset modified failed|" +
|
"reset modified failed|" +
|
||||||
std::to_string(utils::get_last_error_code()));
|
std::to_string(utils::get_last_error_code()),
|
||||||
|
function_name, item.source_path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not utils::file::file(item.source_path).copy_to(orphaned_file, true)) {
|
if (not utils::file::file(item.source_path).copy_to(orphaned_file, true)) {
|
||||||
[[maybe_unused]] auto removed = utils::file::file{orphaned_file}.remove();
|
[[maybe_unused]] auto removed = utils::file::file{orphaned_file}.remove();
|
||||||
event_system::instance().raise<orphaned_file_processing_failed>(
|
event_system2::instance().raise<orphaned_file_processing_failed>(
|
||||||
item.source_path, orphaned_file,
|
orphaned_file,
|
||||||
"copy failed|" + std::to_string(utils::get_last_error_code()));
|
"copy failed|" + std::to_string(utils::get_last_error_code()),
|
||||||
|
function_name, item.source_path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not fm_->evict_file(item.api_path)) {
|
if (not fm_->evict_file(item.api_path)) {
|
||||||
event_system::instance().raise<orphaned_file_processing_failed>(
|
event_system2::instance().raise<orphaned_file_processing_failed>(
|
||||||
item.source_path, orphaned_file, "eviction failed");
|
orphaned_file, "eviction failed", function_name, item.source_path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
db3_->remove_api_path(item.api_path);
|
db3_->remove_api_path(item.api_path);
|
||||||
event_system::instance().raise<file_removed_externally>(item.api_path,
|
event_system2::instance().raise<file_removed_externally>(item.api_path,
|
||||||
item.source_path);
|
item.source_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,12 +626,14 @@ void base_provider::remove_deleted_items(stop_type &stop_requested) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto base_provider::remove_file(const std::string &api_path) -> api_error {
|
auto base_provider::remove_file(const std::string &api_path) -> api_error {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto notify_end = [&api_path](api_error error) -> api_error {
|
const auto notify_end = [&api_path](api_error error) -> api_error {
|
||||||
if (error == api_error::success) {
|
if (error == api_error::success) {
|
||||||
event_system::instance().raise<file_removed>(api_path);
|
event_system2::instance().raise<file_removed>(api_path, function_name);
|
||||||
} else {
|
} else {
|
||||||
event_system::instance().raise<file_remove_failed>(
|
event_system2::instance().raise<file_remove_failed>(api_path, error,
|
||||||
api_path, api_error_to_string(error));
|
function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -648,8 +661,8 @@ auto base_provider::remove_file(const std::string &api_path) -> api_error {
|
|||||||
return notify_end(res);
|
return notify_end(res);
|
||||||
}
|
}
|
||||||
if (not exists) {
|
if (not exists) {
|
||||||
event_system::instance().raise<file_remove_failed>(
|
event_system2::instance().raise<file_remove_failed>(
|
||||||
api_path, api_error_to_string(api_error::item_not_found));
|
api_path, api_error::item_not_found, function_name);
|
||||||
return remove_file_meta();
|
return remove_file_meta();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,14 +751,14 @@ void base_provider::remove_unmatched_source_files(stop_type &stop_requested) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<orphaned_source_file_detected>(
|
event_system2::instance().raise<orphaned_source_file_detected>(
|
||||||
source_file->get_path());
|
function_name, source_file->get_path());
|
||||||
if (not source_file->remove()) {
|
if (not source_file->remove()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<orphaned_source_file_removed>(
|
event_system2::instance().raise<orphaned_source_file_removed>(
|
||||||
source_file->get_path());
|
function_name, source_file->get_path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,6 +775,8 @@ auto base_provider::set_item_meta(const std::string &api_path,
|
|||||||
|
|
||||||
auto base_provider::start(api_item_added_callback api_item_added,
|
auto base_provider::start(api_item_added_callback api_item_added,
|
||||||
i_file_manager *mgr) -> bool {
|
i_file_manager *mgr) -> bool {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
api_item_added_ = api_item_added;
|
api_item_added_ = api_item_added;
|
||||||
fm_ = mgr;
|
fm_ = mgr;
|
||||||
|
|
||||||
@ -795,8 +810,8 @@ auto base_provider::start(api_item_added_callback api_item_added,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<provider_offline>(
|
event_system2::instance().raise<provider_offline>(
|
||||||
cfg.get_host_config().host_name_or_ip,
|
function_name, cfg.get_host_config().host_name_or_ip,
|
||||||
cfg.get_host_config().api_port);
|
cfg.get_host_config().api_port);
|
||||||
std::this_thread::sleep_for(1s);
|
std::this_thread::sleep_for(1s);
|
||||||
}
|
}
|
||||||
@ -830,14 +845,14 @@ auto base_provider::upload_file(const std::string &api_path,
|
|||||||
|
|
||||||
const auto notify_end = [&api_path,
|
const auto notify_end = [&api_path,
|
||||||
&source_path](api_error error) -> api_error {
|
&source_path](api_error error) -> api_error {
|
||||||
event_system::instance().raise<provider_upload_end>(api_path, source_path,
|
event_system2::instance().raise<provider_upload_end>(
|
||||||
error);
|
api_path, error, function_name, source_path);
|
||||||
return error;
|
return error;
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
event_system::instance().raise<provider_upload_begin>(api_path,
|
event_system2::instance().raise<provider_upload_begin>(
|
||||||
source_path);
|
api_path, function_name, source_path);
|
||||||
|
|
||||||
return notify_end(upload_file_impl(api_path, source_path, stop_requested));
|
return notify_end(upload_file_impl(api_path, source_path, stop_requested));
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
@ -22,10 +22,14 @@
|
|||||||
#include "providers/encrypt/encrypt_provider.hpp"
|
#include "providers/encrypt/encrypt_provider.hpp"
|
||||||
|
|
||||||
#include "db/file_db.hpp"
|
#include "db/file_db.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "events/types/directory_removed_externally.hpp"
|
#include "events/types/directory_removed_externally.hpp"
|
||||||
|
#include "events/types/file_removed_externally.hpp"
|
||||||
|
#include "events/types/filesystem_item_added.hpp"
|
||||||
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "types/startup_exception.hpp"
|
#include "types/startup_exception.hpp"
|
||||||
#include "utils/collection.hpp"
|
#include "utils/collection.hpp"
|
||||||
@ -644,9 +648,9 @@ auto encrypt_provider::process_directory_entry(
|
|||||||
api_error_to_string(result)));
|
api_error_to_string(result)));
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<filesystem_item_added>(
|
event_system2::instance().raise<filesystem_item_added>(
|
||||||
current_api_path,
|
utils::path::get_parent_api_path(current_api_path),
|
||||||
utils::path::get_parent_api_path(current_api_path), true);
|
current_api_path, true, function_name);
|
||||||
} else {
|
} else {
|
||||||
if (result != api_error::success) {
|
if (result != api_error::success) {
|
||||||
std::runtime_error(
|
std::runtime_error(
|
||||||
@ -722,8 +726,8 @@ auto encrypt_provider::process_directory_entry(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<filesystem_item_added>(
|
event_system2::instance().raise<filesystem_item_added>(
|
||||||
api_path, api_parent, false);
|
api_parent, api_path, false, function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -856,7 +860,7 @@ void encrypt_provider::remove_deleted_files(stop_type &stop_requested) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<file_removed_externally>(
|
event_system2::instance().raise<file_removed_externally>(
|
||||||
item.api_path, item.source_path);
|
item.api_path, item.source_path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -871,6 +875,7 @@ auto encrypt_provider::start(api_item_added_callback /*api_item_added*/,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_system2::instance().raise<service_start_begin>("encrypt_provider");
|
||||||
db_ = create_file_db(config_);
|
db_ = create_file_db(config_);
|
||||||
|
|
||||||
std::string source_path;
|
std::string source_path;
|
||||||
@ -907,14 +912,14 @@ auto encrypt_provider::start(api_item_added_callback /*api_item_added*/,
|
|||||||
[this](auto &&stop_requested) { remove_deleted_files(stop_requested); },
|
[this](auto &&stop_requested) { remove_deleted_files(stop_requested); },
|
||||||
});
|
});
|
||||||
|
|
||||||
event_system::instance().raise<service_started>("encrypt_provider");
|
event_system2::instance().raise<service_start_end>("encrypt_provider");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void encrypt_provider::stop() {
|
void encrypt_provider::stop() {
|
||||||
event_system::instance().raise<service_shutdown_begin>("encrypt_provider");
|
event_system2::instance().raise<service_stop_begin>("encrypt_provider");
|
||||||
polling::instance().remove_callback("check_deleted");
|
polling::instance().remove_callback("check_deleted");
|
||||||
db_.reset();
|
db_.reset();
|
||||||
event_system::instance().raise<service_shutdown_end>("encrypt_provider");
|
event_system2::instance().raise<service_stop_end>("encrypt_provider");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -23,8 +23,11 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "comm/i_http_comm.hpp"
|
#include "comm/i_http_comm.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "types/s3.hpp"
|
#include "types/s3.hpp"
|
||||||
@ -1044,16 +1047,18 @@ auto s3_provider::set_meta_key(const std::string &api_path, api_meta_map &meta)
|
|||||||
|
|
||||||
auto s3_provider::start(api_item_added_callback api_item_added,
|
auto s3_provider::start(api_item_added_callback api_item_added,
|
||||||
i_file_manager *mgr) -> bool {
|
i_file_manager *mgr) -> bool {
|
||||||
event_system::instance().raise<service_started>("s3_provider");
|
event_system2::instance().raise<service_start_begin>("s3_provider");
|
||||||
s3_config_ = get_config().get_s3_config();
|
s3_config_ = get_config().get_s3_config();
|
||||||
get_comm().enable_s3_path_style(s3_config_.use_path_style);
|
get_comm().enable_s3_path_style(s3_config_.use_path_style);
|
||||||
return base_provider::start(api_item_added, mgr);
|
auto ret = base_provider::start(api_item_added, mgr);
|
||||||
|
event_system2::instance().raise<service_start_end>("s3_provider");
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
void s3_provider::stop() {
|
void s3_provider::stop() {
|
||||||
event_system::instance().raise<service_shutdown_begin>("s3_provider");
|
event_system2::instance().raise<service_stop_begin>("s3_provider");
|
||||||
base_provider::stop();
|
base_provider::stop();
|
||||||
event_system::instance().raise<service_shutdown_end>("s3_provider");
|
event_system2::instance().raise<service_stop_end>("s3_provider");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::upload_file_impl(const std::string &api_path,
|
auto s3_provider::upload_file_impl(const std::string &api_path,
|
||||||
|
@ -23,7 +23,11 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "comm/i_http_comm.hpp"
|
#include "comm/i_http_comm.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "providers/base_provider.hpp"
|
#include "providers/base_provider.hpp"
|
||||||
#include "providers/s3/s3_provider.hpp"
|
#include "providers/s3/s3_provider.hpp"
|
||||||
@ -740,15 +744,17 @@ auto sia_provider::rename_file(const std::string &from_api_path,
|
|||||||
|
|
||||||
auto sia_provider::start(api_item_added_callback api_item_added,
|
auto sia_provider::start(api_item_added_callback api_item_added,
|
||||||
i_file_manager *mgr) -> bool {
|
i_file_manager *mgr) -> bool {
|
||||||
event_system::instance().raise<service_started>("sia_provider");
|
event_system2::instance().raise<service_start_begin>("sia_provider");
|
||||||
sia_config_ = get_config().get_sia_config();
|
sia_config_ = get_config().get_sia_config();
|
||||||
return base_provider::start(api_item_added, mgr);
|
auto ret = base_provider::start(api_item_added, mgr);
|
||||||
|
event_system2::instance().raise<service_start_end>("sia_provider");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sia_provider::stop() {
|
void sia_provider::stop() {
|
||||||
event_system::instance().raise<service_shutdown_begin>("sia_provider");
|
event_system2::instance().raise<service_stop_begin>("sia_provider");
|
||||||
base_provider::stop();
|
base_provider::stop();
|
||||||
event_system::instance().raise<service_shutdown_end>("sia_provider");
|
event_system2::instance().raise<service_stop_end>("sia_provider");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::upload_file_impl(const std::string &api_path,
|
auto sia_provider::upload_file_impl(const std::string &api_path,
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
#include "rpc/server/full_server.hpp"
|
#include "rpc/server/full_server.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/file_pinned.hpp"
|
||||||
|
#include "events/types/file_unpinned.hpp"
|
||||||
#include "file_manager/cache_size_mgr.hpp"
|
#include "file_manager/cache_size_mgr.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
@ -46,7 +47,7 @@ void full_server::handle_get_directory_items(const httplib::Request &req,
|
|||||||
})
|
})
|
||||||
.dump(),
|
.dump(),
|
||||||
"application/json");
|
"application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::handle_get_drive_information(const httplib::Request & /*req*/,
|
void full_server::handle_get_drive_information(const httplib::Request & /*req*/,
|
||||||
@ -60,7 +61,7 @@ void full_server::handle_get_drive_information(const httplib::Request & /*req*/,
|
|||||||
})
|
})
|
||||||
.dump(),
|
.dump(),
|
||||||
"application/json");
|
"application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::handle_get_open_files(const httplib::Request & /*req*/,
|
void full_server::handle_get_open_files(const httplib::Request & /*req*/,
|
||||||
@ -75,7 +76,7 @@ void full_server::handle_get_open_files(const httplib::Request & /*req*/,
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
res.set_content(open_files.dump(), "application/json");
|
res.set_content(open_files.dump(), "application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::handle_get_pinned_files(const httplib::Request & /*req*/,
|
void full_server::handle_get_pinned_files(const httplib::Request & /*req*/,
|
||||||
@ -85,7 +86,7 @@ void full_server::handle_get_pinned_files(const httplib::Request & /*req*/,
|
|||||||
})
|
})
|
||||||
.dump(),
|
.dump(),
|
||||||
"application/json");
|
"application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::handle_get_pinned_status(const httplib::Request &req,
|
void full_server::handle_get_pinned_status(const httplib::Request &req,
|
||||||
@ -99,7 +100,7 @@ void full_server::handle_get_pinned_status(const httplib::Request &req,
|
|||||||
if (result != api_error::success) {
|
if (result != api_error::success) {
|
||||||
utils::error::raise_api_path_error(function_name, api_path, result,
|
utils::error::raise_api_path_error(function_name, api_path, result,
|
||||||
"failed to get pinned status");
|
"failed to get pinned status");
|
||||||
res.status = 500;
|
res.status = http_error_codes::internal_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ void full_server::handle_get_pinned_status(const httplib::Request &req,
|
|||||||
})
|
})
|
||||||
.dump(),
|
.dump(),
|
||||||
"application/json");
|
"application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::handle_pin_file(const httplib::Request &req,
|
void full_server::handle_pin_file(const httplib::Request &req,
|
||||||
@ -124,7 +125,7 @@ void full_server::handle_pin_file(const httplib::Request &req,
|
|||||||
if (result != api_error::success) {
|
if (result != api_error::success) {
|
||||||
utils::error::raise_api_path_error(function_name, api_path, result,
|
utils::error::raise_api_path_error(function_name, api_path, result,
|
||||||
"failed to pin file");
|
"failed to pin file");
|
||||||
res.status = 500;
|
res.status = http_error_codes::internal_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +136,10 @@ void full_server::handle_pin_file(const httplib::Request &req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
event_system::instance().raise<file_pinned>(api_path);
|
event_system2::instance().raise<file_pinned>(api_path, function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status = exists ? 200 : 404;
|
res.status = exists ? http_error_codes::ok : http_error_codes::not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::handle_unpin_file(const httplib::Request &req,
|
void full_server::handle_unpin_file(const httplib::Request &req,
|
||||||
@ -152,7 +153,7 @@ void full_server::handle_unpin_file(const httplib::Request &req,
|
|||||||
if (result != api_error::success) {
|
if (result != api_error::success) {
|
||||||
utils::error::raise_api_path_error(function_name, api_path, result,
|
utils::error::raise_api_path_error(function_name, api_path, result,
|
||||||
"failed to unpin file");
|
"failed to unpin file");
|
||||||
res.status = 500;
|
res.status = http_error_codes::internal_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,10 +164,10 @@ void full_server::handle_unpin_file(const httplib::Request &req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
event_system::instance().raise<file_unpinned>(api_path);
|
event_system2::instance().raise<file_unpinned>(api_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status = exists ? 200 : 404;
|
res.status = exists ? http_error_codes::ok : http_error_codes::not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_server::initialize(httplib::Server &inst) {
|
void full_server::initialize(httplib::Server &inst) {
|
||||||
|
@ -22,8 +22,11 @@
|
|||||||
#include "rpc/server/server.hpp"
|
#include "rpc/server/server.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "utils/base64.hpp"
|
#include "utils/base64.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
|
||||||
@ -82,7 +85,7 @@ void server::handle_get_config(const httplib::Request & /*req*/,
|
|||||||
httplib::Response &res) {
|
httplib::Response &res) {
|
||||||
auto data = config_.get_json();
|
auto data = config_.get_json();
|
||||||
res.set_content(data.dump(), "application/json");
|
res.set_content(data.dump(), "application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::handle_get_config_value_by_name(const httplib::Request &req,
|
void server::handle_get_config_value_by_name(const httplib::Request &req,
|
||||||
@ -90,7 +93,7 @@ void server::handle_get_config_value_by_name(const httplib::Request &req,
|
|||||||
auto name = req.get_param_value("name");
|
auto name = req.get_param_value("name");
|
||||||
auto data = json({{"value", config_.get_value_by_name(name)}});
|
auto data = json({{"value", config_.get_value_by_name(name)}});
|
||||||
res.set_content(data.dump(), "application/json");
|
res.set_content(data.dump(), "application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::handle_set_config_value_by_name(const httplib::Request &req,
|
void server::handle_set_config_value_by_name(const httplib::Request &req,
|
||||||
@ -100,13 +103,13 @@ void server::handle_set_config_value_by_name(const httplib::Request &req,
|
|||||||
|
|
||||||
json data = {{"value", config_.set_value_by_name(name, value)}};
|
json data = {{"value", config_.set_value_by_name(name, value)}};
|
||||||
res.set_content(data.dump(), "application/json");
|
res.set_content(data.dump(), "application/json");
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::handle_unmount(const httplib::Request & /*req*/,
|
void server::handle_unmount(const httplib::Request & /*req*/,
|
||||||
httplib::Response &res) {
|
httplib::Response &res) {
|
||||||
event_system::instance().raise<unmount_requested>();
|
event_system2::instance().raise<unmount_requested>();
|
||||||
res.status = 200;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::initialize(httplib::Server &inst) {
|
void server::initialize(httplib::Server &inst) {
|
||||||
@ -141,7 +144,8 @@ void server::start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_started>("server");
|
event_system2::instance().raise<service_start_begin>("server");
|
||||||
|
|
||||||
server_ = std::make_unique<httplib::Server>();
|
server_ = std::make_unique<httplib::Server>();
|
||||||
|
|
||||||
server_->set_exception_handler([](const httplib::Request &req,
|
server_->set_exception_handler([](const httplib::Request &req,
|
||||||
@ -162,7 +166,7 @@ void server::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.set_content(data.dump(), "application/json");
|
res.set_content(data.dump(), "application/json");
|
||||||
res.status = 500;
|
res.status = http_error_codes::internal_error;
|
||||||
});
|
});
|
||||||
|
|
||||||
server_->set_pre_routing_handler(
|
server_->set_pre_routing_handler(
|
||||||
@ -171,7 +175,7 @@ void server::start() {
|
|||||||
return httplib::Server::HandlerResponse::Unhandled;
|
return httplib::Server::HandlerResponse::Unhandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status = 401;
|
res.status = http_error_codes::unauthorized;
|
||||||
return httplib::Server::HandlerResponse::Handled;
|
return httplib::Server::HandlerResponse::Handled;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -179,6 +183,7 @@ void server::start() {
|
|||||||
|
|
||||||
server_thread_ = std::make_unique<std::thread>(
|
server_thread_ = std::make_unique<std::thread>(
|
||||||
[this]() { server_->listen("127.0.0.1", config_.get_api_port()); });
|
[this]() { server_->listen("127.0.0.1", config_.get_api_port()); });
|
||||||
|
event_system2::instance().raise<service_start_end>("server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::stop() {
|
void server::stop() {
|
||||||
@ -187,7 +192,7 @@ void server::stop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_begin>("server");
|
event_system2::instance().raise<service_stop_begin>("server");
|
||||||
|
|
||||||
server_->stop();
|
server_->stop();
|
||||||
|
|
||||||
@ -202,6 +207,6 @@ void server::stop() {
|
|||||||
server_.reset();
|
server_.reset();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_end>("server");
|
event_system2::instance().raise<service_stop_end>("server");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/repertory_exception.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/error.hpp"
|
#include "utils/error.hpp"
|
||||||
|
|
||||||
@ -53,67 +53,64 @@ std::unique_ptr<repertory_exception_handler> handler{([]() -> auto * {
|
|||||||
|
|
||||||
namespace repertory::utils::error {
|
namespace repertory::utils::error {
|
||||||
void raise_error(std::string_view function, std::string_view msg) {
|
void raise_error(std::string_view function, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function), static_cast<std::string>(msg));
|
function, static_cast<std::string>(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, const api_error &err,
|
void raise_error(std::string_view function, const api_error &err,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
static_cast<std::string>(msg) + "|err|" + api_error_to_string(err));
|
static_cast<std::string>(msg) + "|err|" + api_error_to_string(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, const std::exception &exception) {
|
void raise_error(std::string_view function, const std::exception &exception) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
"err|" + std::string(exception.what() == nullptr ? "unknown error"
|
"err|" + std::string(exception.what() == nullptr ? "unknown error"
|
||||||
: exception.what()));
|
: exception.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, const std::exception &exception,
|
void raise_error(std::string_view function, const std::exception &exception,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
static_cast<std::string>(msg) + "|err|" +
|
static_cast<std::string>(msg) + "|err|" +
|
||||||
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, const json &err,
|
void raise_error(std::string_view function, const json &err,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|err|" + err.dump(2));
|
||||||
static_cast<std::string>(msg) + "|err|" + err.dump(2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, std::int64_t err,
|
void raise_error(std::string_view function, std::int64_t err,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|err|" + std::to_string(err));
|
||||||
static_cast<std::string>(msg) + "|err|" + std::to_string(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, const api_error &err,
|
void raise_error(std::string_view function, const api_error &err,
|
||||||
std::string_view file_path, std::string_view msg) {
|
std::string_view file_path, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|sp|" +
|
||||||
static_cast<std::string>(msg) + "|sp|" +
|
static_cast<std::string>(file_path) + "|err|" +
|
||||||
static_cast<std::string>(file_path) + "|err|" +
|
api_error_to_string(err));
|
||||||
api_error_to_string(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, std::int64_t err,
|
void raise_error(std::string_view function, std::int64_t err,
|
||||||
std::string_view file_path, std::string_view msg) {
|
std::string_view file_path, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|sp|" +
|
||||||
static_cast<std::string>(msg) + "|sp|" +
|
static_cast<std::string>(file_path) + "|err|" +
|
||||||
static_cast<std::string>(file_path) + "|err|" + std::to_string(err));
|
std::to_string(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_error(std::string_view function, const std::exception &exception,
|
void raise_error(std::string_view function, const std::exception &exception,
|
||||||
std::string_view file_path, std::string_view msg) {
|
std::string_view file_path, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
static_cast<std::string>(msg) + "|sp|" +
|
static_cast<std::string>(msg) + "|sp|" +
|
||||||
static_cast<std::string>(file_path) + "|err|" +
|
static_cast<std::string>(file_path) + "|err|" +
|
||||||
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
||||||
@ -121,25 +118,24 @@ void raise_error(std::string_view function, const std::exception &exception,
|
|||||||
|
|
||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
const api_error &err, std::string_view msg) {
|
const api_error &err, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(api_path) + "|err|" +
|
||||||
static_cast<std::string>(api_path) + "|err|" +
|
api_error_to_string(err));
|
||||||
api_error_to_string(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
std::int64_t err, std::string_view msg) {
|
std::int64_t err, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(api_path) + "|err|" +
|
||||||
static_cast<std::string>(api_path) + "|err|" + std::to_string(err));
|
std::to_string(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
const std::exception &exception) {
|
const std::exception &exception) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
"ap|" + static_cast<std::string>(api_path) + "|err|" +
|
"ap|" + static_cast<std::string>(api_path) + "|err|" +
|
||||||
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
||||||
}
|
}
|
||||||
@ -147,8 +143,8 @@ void raise_api_path_error(std::string_view function, std::string_view api_path,
|
|||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
const std::exception &exception,
|
const std::exception &exception,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(api_path) + "|err|" +
|
static_cast<std::string>(api_path) + "|err|" +
|
||||||
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
||||||
@ -157,39 +153,36 @@ void raise_api_path_error(std::string_view function, std::string_view api_path,
|
|||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
std::string_view source_path, const api_error &err,
|
std::string_view source_path, const api_error &err,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(api_path) + "|sp|" +
|
||||||
static_cast<std::string>(api_path) + "|sp|" +
|
static_cast<std::string>(source_path) + "|err|" +
|
||||||
static_cast<std::string>(source_path) + "|err|" +
|
api_error_to_string(err));
|
||||||
api_error_to_string(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
std::string_view source_path, std::int64_t err,
|
std::string_view source_path, std::int64_t err,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(api_path) + "|sp|" +
|
||||||
static_cast<std::string>(api_path) + "|sp|" +
|
static_cast<std::string>(source_path) + "|err|" +
|
||||||
static_cast<std::string>(source_path) + "|err|" +
|
std::to_string(err));
|
||||||
std::to_string(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
const json &err, std::string_view msg) {
|
const json &err, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(api_path) + "|err|" + err.dump(2));
|
||||||
static_cast<std::string>(api_path) + "|err|" + err.dump(2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||||
std::string_view source_path,
|
std::string_view source_path,
|
||||||
const std::exception &exception,
|
const std::exception &exception,
|
||||||
std::string_view msg) {
|
std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
static_cast<std::string>(msg) + "|ap|" +
|
static_cast<std::string>(msg) + "|ap|" +
|
||||||
static_cast<std::string>(api_path) + "|sp|" +
|
static_cast<std::string>(api_path) + "|sp|" +
|
||||||
static_cast<std::string>(source_path) + "|err|" +
|
static_cast<std::string>(source_path) + "|err|" +
|
||||||
@ -198,17 +191,17 @@ void raise_api_path_error(std::string_view function, std::string_view api_path,
|
|||||||
|
|
||||||
void raise_url_error(std::string_view function, std::string_view url,
|
void raise_url_error(std::string_view function, std::string_view url,
|
||||||
CURLcode err, std::string_view msg) {
|
CURLcode err, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function, static_cast<std::string>(msg) + "|url|" +
|
||||||
static_cast<std::string>(msg) + "|url|" + static_cast<std::string>(url) +
|
static_cast<std::string>(url) + "|err|" +
|
||||||
"|err|" + curl_easy_strerror(err));
|
curl_easy_strerror(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
void raise_url_error(std::string_view function, std::string_view url,
|
void raise_url_error(std::string_view function, std::string_view url,
|
||||||
std::string_view source_path,
|
std::string_view source_path,
|
||||||
const std::exception &exception) {
|
const std::exception &exception) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
"url|" + static_cast<std::string>(url) + "|sp|" +
|
"url|" + static_cast<std::string>(url) + "|sp|" +
|
||||||
static_cast<std::string>(source_path) + "|err|" +
|
static_cast<std::string>(source_path) + "|err|" +
|
||||||
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
||||||
@ -217,8 +210,8 @@ void raise_url_error(std::string_view function, std::string_view url,
|
|||||||
void raise_url_error(std::string_view function, std::string_view url,
|
void raise_url_error(std::string_view function, std::string_view url,
|
||||||
std::string_view source_path,
|
std::string_view source_path,
|
||||||
const std::exception &exception, std::string_view msg) {
|
const std::exception &exception, std::string_view msg) {
|
||||||
event_system::instance().raise<repertory_exception>(
|
event_system2::instance().raise<repertory_exception>(
|
||||||
static_cast<std::string>(function),
|
function,
|
||||||
static_cast<std::string>(msg) + "|url|" + static_cast<std::string>(url) +
|
static_cast<std::string>(msg) + "|url|" + static_cast<std::string>(url) +
|
||||||
"|sp|" + static_cast<std::string>(source_path) + "|err|" +
|
"|sp|" + static_cast<std::string>(source_path) + "|err|" +
|
||||||
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
(exception.what() == nullptr ? "unknown error" : exception.what()));
|
||||||
|
@ -22,8 +22,13 @@
|
|||||||
#include "utils/polling.hpp"
|
#include "utils/polling.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/polling_item_begin.hpp"
|
||||||
|
#include "events/types/polling_item_end.hpp"
|
||||||
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "utils/tasks.hpp"
|
#include "utils/tasks.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
@ -31,6 +36,8 @@ polling polling::instance_;
|
|||||||
|
|
||||||
void polling::frequency_thread(
|
void polling::frequency_thread(
|
||||||
std::function<std::uint32_t()> get_frequency_seconds, frequency freq) {
|
std::function<std::uint32_t()> get_frequency_seconds, frequency freq) {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
while (not get_stop_requested()) {
|
while (not get_stop_requested()) {
|
||||||
unique_mutex_lock lock(mutex_);
|
unique_mutex_lock lock(mutex_);
|
||||||
auto futures = std::accumulate(
|
auto futures = std::accumulate(
|
||||||
@ -44,13 +51,14 @@ void polling::frequency_thread(
|
|||||||
[this, &freq, item](auto &&task_stopped) {
|
[this, &freq, item](auto &&task_stopped) {
|
||||||
if (config_->get_event_level() == event_level::trace ||
|
if (config_->get_event_level() == event_level::trace ||
|
||||||
freq != frequency::second) {
|
freq != frequency::second) {
|
||||||
event_system::instance().raise<polling_item_begin>(
|
event_system2::instance().raise<polling_item_begin>(
|
||||||
item.first);
|
function_name, item.first);
|
||||||
}
|
}
|
||||||
item.second.action(task_stopped);
|
item.second.action(task_stopped);
|
||||||
if (config_->get_event_level() == event_level::trace ||
|
if (config_->get_event_level() == event_level::trace ||
|
||||||
freq != frequency::second) {
|
freq != frequency::second) {
|
||||||
event_system::instance().raise<polling_item_end>(item.first);
|
event_system2::instance().raise<polling_item_end>(
|
||||||
|
function_name, item.first);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -94,7 +102,7 @@ void polling::start(app_config *config) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_started>("polling");
|
event_system2::instance().raise<service_start_begin>("polling");
|
||||||
config_ = config;
|
config_ = config;
|
||||||
stop_requested_ = false;
|
stop_requested_ = false;
|
||||||
|
|
||||||
@ -133,6 +141,7 @@ void polling::start(app_config *config) {
|
|||||||
this->frequency_thread([]() -> std::uint32_t { return 1U; },
|
this->frequency_thread([]() -> std::uint32_t { return 1U; },
|
||||||
frequency::second);
|
frequency::second);
|
||||||
});
|
});
|
||||||
|
event_system2::instance().raise<service_start_end>("polling");
|
||||||
}
|
}
|
||||||
|
|
||||||
void polling::stop() {
|
void polling::stop() {
|
||||||
@ -141,7 +150,7 @@ void polling::stop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_begin>("polling");
|
event_system2::instance().raise<service_stop_begin>("polling");
|
||||||
|
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
@ -160,6 +169,6 @@ void polling::stop() {
|
|||||||
thread.reset();
|
thread.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_end>("polling");
|
event_system2::instance().raise<service_stop_end>("polling");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -22,8 +22,11 @@
|
|||||||
#include "utils/single_thread_service_base.hpp"
|
#include "utils/single_thread_service_base.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
@ -45,7 +48,8 @@ void single_thread_service_base::start() {
|
|||||||
stop_requested_ = false;
|
stop_requested_ = false;
|
||||||
on_start();
|
on_start();
|
||||||
thread_ = std::make_unique<std::thread>([this]() {
|
thread_ = std::make_unique<std::thread>([this]() {
|
||||||
event_system::instance().raise<service_started>(service_name_);
|
event_system2::instance().raise<service_start_begin>(service_name_);
|
||||||
|
event_system2::instance().raise<service_start_end>(service_name_);
|
||||||
while (not get_stop_requested()) {
|
while (not get_stop_requested()) {
|
||||||
service_function();
|
service_function();
|
||||||
}
|
}
|
||||||
@ -58,7 +62,7 @@ void single_thread_service_base::stop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_begin>(service_name_);
|
event_system2::instance().raise<service_stop_begin>(service_name_);
|
||||||
|
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
@ -73,6 +77,6 @@ void single_thread_service_base::stop() {
|
|||||||
|
|
||||||
on_stop();
|
on_stop();
|
||||||
|
|
||||||
event_system::instance().raise<service_shutdown_end>(service_name_);
|
event_system2::instance().raise<service_stop_end>(service_name_);
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "db/impl/rdb_file_db.hpp"
|
#include "db/impl/rdb_file_db.hpp"
|
||||||
#include "db/impl/sqlite_file_db.hpp"
|
#include "db/impl/sqlite_file_db.hpp"
|
||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
template <typename db_t> class file_db_test : public ::testing::Test {
|
template <typename db_t> class file_db_test : public ::testing::Test {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "db/impl/rdb_file_mgr_db.hpp"
|
#include "db/impl/rdb_file_mgr_db.hpp"
|
||||||
#include "db/impl/sqlite_file_mgr_db.hpp"
|
#include "db/impl/sqlite_file_mgr_db.hpp"
|
||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
template <typename db_t> class file_mgr_db_test : public ::testing::Test {
|
template <typename db_t> class file_mgr_db_test : public ::testing::Test {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "db/impl/rdb_meta_db.hpp"
|
#include "db/impl/rdb_meta_db.hpp"
|
||||||
#include "db/impl/sqlite_meta_db.hpp"
|
#include "db/impl/sqlite_meta_db.hpp"
|
||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
template <typename db_t> class meta_db_test : public ::testing::Test {
|
template <typename db_t> class meta_db_test : public ::testing::Test {
|
||||||
|
@ -27,8 +27,6 @@ REPERTORY_IGNORE_WARNINGS_ENABLE()
|
|||||||
REPERTORY_IGNORE_WARNINGS_DISABLE()
|
REPERTORY_IGNORE_WARNINGS_DISABLE()
|
||||||
|
|
||||||
#include "events/consumers/console_consumer.hpp"
|
#include "events/consumers/console_consumer.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/events.hpp"
|
|
||||||
|
|
||||||
#endif // REPERTORY_TEST_INCLUDE_TEST_COMMON_HPP_
|
#endif // REPERTORY_TEST_INCLUDE_TEST_COMMON_HPP_
|
||||||
|
@ -29,20 +29,20 @@
|
|||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class event_capture final {
|
class event_capture final {
|
||||||
E_CONSUMER();
|
E_CONSUMER2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit event_capture(std::vector<std::string> event_names,
|
explicit event_capture(std::vector<std::string> event_names,
|
||||||
std::vector<std::string> non_fired_event_names = {})
|
std::vector<std::string> non_fired_event_names = {})
|
||||||
: event_names_(std::move(event_names)),
|
: event_names_(std::move(event_names)),
|
||||||
non_fired_event_names_(std::move(non_fired_event_names)) {
|
non_fired_event_names_(std::move(non_fired_event_names)) {
|
||||||
E_SUBSCRIBE_ALL(process_event);
|
E_SUBSCRIBE2_ALL(process_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
~event_capture() {
|
~event_capture() {
|
||||||
wait_for_empty();
|
wait_for_empty();
|
||||||
|
|
||||||
E_CONSUMER_RELEASE();
|
E_CONSUMER2_RELEASE();
|
||||||
|
|
||||||
EXPECT_TRUE(event_names_.empty());
|
EXPECT_TRUE(event_names_.empty());
|
||||||
for (const auto &event_name : event_names_) {
|
for (const auto &event_name : event_names_) {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "test_common.hpp"
|
#include "test_common.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "utils/common.hpp"
|
#include "utils/common.hpp"
|
||||||
#include "utils/file_utils.hpp"
|
#include "utils/file_utils.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
|
@ -22,8 +22,11 @@
|
|||||||
#include "test_common.hpp"
|
#include "test_common.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
|
#include "events/types/service_start_begin.hpp"
|
||||||
|
#include "events/types/service_start_end.hpp"
|
||||||
|
#include "events/types/service_stop_begin.hpp"
|
||||||
|
#include "events/types/service_stop_end.hpp"
|
||||||
#include "file_manager/cache_size_mgr.hpp"
|
#include "file_manager/cache_size_mgr.hpp"
|
||||||
#include "file_manager/events.hpp"
|
|
||||||
#include "file_manager/file_manager.hpp"
|
#include "file_manager/file_manager.hpp"
|
||||||
#include "file_manager/i_open_file.hpp"
|
#include "file_manager/i_open_file.hpp"
|
||||||
#include "mocks/mock_open_file.hpp"
|
#include "mocks/mock_open_file.hpp"
|
||||||
@ -84,23 +87,23 @@ std::atomic<std::size_t> file_manager_test::inst{0U};
|
|||||||
TEST_F(file_manager_test, can_start_and_stop) {
|
TEST_F(file_manager_test, can_start_and_stop) {
|
||||||
EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false));
|
EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false));
|
||||||
|
|
||||||
event_consumer consumer("service_started", [](const event &evt) {
|
event_consumer consumer("service_start_begin", [](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const service_started &>(evt);
|
const auto &evt2 = dynamic_cast<const service_start_begin &>(evt);
|
||||||
EXPECT_STREQ("file_manager", evt2.get_service().get<std::string>().c_str());
|
EXPECT_STREQ("file_manager", evt2.service_name.c_str());
|
||||||
});
|
});
|
||||||
event_consumer consumer2("service_shutdown_begin", [](const event &evt) {
|
event_consumer consumer2("service_stop_begin", [](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const service_shutdown_begin &>(evt);
|
const auto &evt2 = dynamic_cast<const service_stop_begin &>(evt);
|
||||||
EXPECT_STREQ("file_manager", evt2.get_service().get<std::string>().c_str());
|
EXPECT_STREQ("file_manager", evt2.service_name.c_str());
|
||||||
});
|
});
|
||||||
event_consumer consumer3("service_shutdown_end", [](const event &evt) {
|
event_consumer consumer3("service_stop_end", [](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const service_shutdown_end &>(evt);
|
const auto &evt2 = dynamic_cast<const service_stop_end &>(evt);
|
||||||
EXPECT_STREQ("file_manager", evt2.get_service().get<std::string>().c_str());
|
EXPECT_STREQ("file_manager", evt2.service_name.c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
event_capture capture({
|
event_capture capture({
|
||||||
"service_started",
|
"service_start_begin",
|
||||||
"service_shutdown_begin",
|
"service_stop_begin",
|
||||||
"service_shutdown_end",
|
"service_stop_end",
|
||||||
});
|
});
|
||||||
|
|
||||||
file_manager mgr(*cfg, mp);
|
file_manager mgr(*cfg, mp);
|
||||||
@ -155,25 +158,22 @@ TEST_F(file_manager_test, can_create_and_close_file) {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
});
|
});
|
||||||
|
|
||||||
event_consumer consumer("filesystem_item_opened", [&](const event &evt) {
|
event_consumer consumer("filesystem_item_opened", [&](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const filesystem_item_opened &>(evt);
|
const auto &evt2 = dynamic_cast<const filesystem_item_opened &>(evt);
|
||||||
EXPECT_STREQ("/test_create.txt",
|
EXPECT_STREQ("/test_create.txt", evt2.api_path.c_str());
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
EXPECT_STREQ(source_path.c_str(), evt2.source_path.c_str());
|
||||||
EXPECT_STREQ(source_path.c_str(),
|
EXPECT_FALSE(evt2.directory);
|
||||||
evt2.get_source().get<std::string>().c_str());
|
|
||||||
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
event_consumer ec2("filesystem_item_handle_opened", [&](const event &evt) {
|
event_consumer ec2(
|
||||||
const auto &evt2 =
|
"filesystem_item_handle_opened", [&](const i_event &evt) {
|
||||||
dynamic_cast<const filesystem_item_handle_opened &>(evt);
|
const auto &evt2 =
|
||||||
EXPECT_STREQ("/test_create.txt",
|
dynamic_cast<const filesystem_item_handle_opened &>(evt);
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
EXPECT_STREQ("/test_create.txt", evt2.api_path.c_str());
|
||||||
EXPECT_STREQ(source_path.c_str(),
|
EXPECT_STREQ(source_path.c_str(), evt2.source_path.c_str());
|
||||||
evt2.get_source().get<std::string>().c_str());
|
EXPECT_FALSE(evt2.directory);
|
||||||
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
EXPECT_EQ(std::uint64_t(1U), evt2.handle);
|
||||||
EXPECT_STREQ("1", evt2.get_handle().get<std::string>().c_str());
|
});
|
||||||
});
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
EXPECT_EQ(api_error::success,
|
EXPECT_EQ(api_error::success,
|
||||||
@ -187,7 +187,7 @@ TEST_F(file_manager_test, can_create_and_close_file) {
|
|||||||
EXPECT_EQ(std::uint64_t(1U), handle);
|
EXPECT_EQ(std::uint64_t(1U), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_consumer ec3("filesystem_item_closed", [&](const event &evt) {
|
event_consumer ec3("filesystem_item_closed", [&](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const filesystem_item_closed &>(evt);
|
const auto &evt2 = dynamic_cast<const filesystem_item_closed &>(evt);
|
||||||
EXPECT_STREQ("/test_create.txt",
|
EXPECT_STREQ("/test_create.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -196,7 +196,7 @@ TEST_F(file_manager_test, can_create_and_close_file) {
|
|||||||
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
event_consumer ec4("filesystem_item_handle_closed", [&](const event &evt) {
|
event_consumer ec4("filesystem_item_handle_closed", [&](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const filesystem_item_handle_closed &>(evt);
|
const auto &evt2 = dynamic_cast<const filesystem_item_handle_closed &>(evt);
|
||||||
EXPECT_STREQ("/test_create.txt",
|
EXPECT_STREQ("/test_create.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -262,7 +262,7 @@ TEST_F(file_manager_test, can_open_and_close_file) {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
});
|
});
|
||||||
|
|
||||||
event_consumer consumer("filesystem_item_opened", [&](const event &evt) {
|
event_consumer consumer("filesystem_item_opened", [&](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const filesystem_item_opened &>(evt);
|
const auto &evt2 = dynamic_cast<const filesystem_item_opened &>(evt);
|
||||||
EXPECT_STREQ("/test_open.txt",
|
EXPECT_STREQ("/test_open.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -271,16 +271,17 @@ TEST_F(file_manager_test, can_open_and_close_file) {
|
|||||||
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
event_consumer ec2("filesystem_item_handle_opened", [&](const event &evt) {
|
event_consumer ec2(
|
||||||
const auto &evt2 =
|
"filesystem_item_handle_opened", [&](const i_event &evt) {
|
||||||
dynamic_cast<const filesystem_item_handle_opened &>(evt);
|
const auto &evt2 =
|
||||||
EXPECT_STREQ("/test_open.txt",
|
dynamic_cast<const filesystem_item_handle_opened &>(evt);
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
EXPECT_STREQ("/test_open.txt",
|
||||||
EXPECT_STREQ(source_path.c_str(),
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
evt2.get_source().get<std::string>().c_str());
|
EXPECT_STREQ(source_path.c_str(),
|
||||||
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
evt2.get_source().get<std::string>().c_str());
|
||||||
EXPECT_STREQ("1", evt2.get_handle().get<std::string>().c_str());
|
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
||||||
});
|
EXPECT_STREQ("1", evt2.get_handle().get<std::string>().c_str());
|
||||||
|
});
|
||||||
|
|
||||||
std::shared_ptr<i_open_file> open_file;
|
std::shared_ptr<i_open_file> open_file;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -295,7 +296,7 @@ TEST_F(file_manager_test, can_open_and_close_file) {
|
|||||||
EXPECT_EQ(std::uint64_t(1U), handle);
|
EXPECT_EQ(std::uint64_t(1U), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_consumer ec3("filesystem_item_closed", [&](const event &evt) {
|
event_consumer ec3("filesystem_item_closed", [&](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const filesystem_item_closed &>(evt);
|
const auto &evt2 = dynamic_cast<const filesystem_item_closed &>(evt);
|
||||||
EXPECT_STREQ("/test_open.txt",
|
EXPECT_STREQ("/test_open.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -304,7 +305,7 @@ TEST_F(file_manager_test, can_open_and_close_file) {
|
|||||||
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
EXPECT_STREQ("0", evt2.get_directory().get<std::string>().c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
event_consumer ec4("filesystem_item_handle_closed", [&](const event &evt) {
|
event_consumer ec4("filesystem_item_handle_closed", [&](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const filesystem_item_handle_closed &>(evt);
|
const auto &evt2 = dynamic_cast<const filesystem_item_handle_closed &>(evt);
|
||||||
EXPECT_STREQ("/test_open.txt",
|
EXPECT_STREQ("/test_open.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -400,7 +401,7 @@ TEST_F(file_manager_test,
|
|||||||
{utils::create_uuid_string()});
|
{utils::create_uuid_string()});
|
||||||
|
|
||||||
event_consumer consumer(
|
event_consumer consumer(
|
||||||
"download_resume_added", [&source_path](const event &evt) {
|
"download_resume_added", [&source_path](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const download_resume_added &>(evt);
|
const auto &evt2 = dynamic_cast<const download_resume_added &>(evt);
|
||||||
EXPECT_STREQ("/test_write_partial_download.txt",
|
EXPECT_STREQ("/test_write_partial_download.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -522,7 +523,7 @@ TEST_F(file_manager_test,
|
|||||||
|
|
||||||
mgr.start();
|
mgr.start();
|
||||||
|
|
||||||
event_consumer es2("download_restored", [&source_path](const event &evt) {
|
event_consumer es2("download_restored", [&source_path](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const download_restored &>(evt);
|
const auto &evt2 = dynamic_cast<const download_restored &>(evt);
|
||||||
EXPECT_STREQ("/test_write_partial_download.txt",
|
EXPECT_STREQ("/test_write_partial_download.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
@ -555,20 +556,21 @@ TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) {
|
|||||||
{utils::create_uuid_string()});
|
{utils::create_uuid_string()});
|
||||||
|
|
||||||
event_consumer consumer(
|
event_consumer consumer(
|
||||||
"file_upload_queued", [&source_path](const event &evt) {
|
"file_upload_queued", [&source_path](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const file_upload_queued &>(evt);
|
const auto &evt2 = dynamic_cast<const file_upload_queued &>(evt);
|
||||||
EXPECT_STREQ("/test_write_full_download.txt",
|
EXPECT_STREQ("/test_write_full_download.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
EXPECT_STREQ(source_path.c_str(),
|
EXPECT_STREQ(source_path.c_str(),
|
||||||
evt2.get_source().get<std::string>().c_str());
|
evt2.get_source().get<std::string>().c_str());
|
||||||
});
|
});
|
||||||
event_consumer es2("file_upload_completed", [&source_path](const event &evt) {
|
event_consumer es2(
|
||||||
const auto &evt2 = dynamic_cast<const file_upload_completed &>(evt);
|
"file_upload_completed", [&source_path](const i_event &evt) {
|
||||||
EXPECT_STREQ("/test_write_full_download.txt",
|
const auto &evt2 = dynamic_cast<const file_upload_completed &>(evt);
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
EXPECT_STREQ("/test_write_full_download.txt",
|
||||||
EXPECT_STREQ(source_path.c_str(),
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
evt2.get_source().get<std::string>().c_str());
|
EXPECT_STREQ(source_path.c_str(),
|
||||||
});
|
evt2.get_source().get<std::string>().c_str());
|
||||||
|
});
|
||||||
|
|
||||||
auto now = utils::time::get_time_now();
|
auto now = utils::time::get_time_now();
|
||||||
auto meta = create_meta_attributes(
|
auto meta = create_meta_attributes(
|
||||||
@ -1445,7 +1447,7 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) {
|
|||||||
auto source_path = utils::path::combine(cfg->get_cache_directory(),
|
auto source_path = utils::path::combine(cfg->get_cache_directory(),
|
||||||
{utils::create_uuid_string()});
|
{utils::create_uuid_string()});
|
||||||
|
|
||||||
event_consumer consumer("item_timeout", [](const event &evt) {
|
event_consumer consumer("item_timeout", [](const i_event &evt) {
|
||||||
const auto &evt2 = dynamic_cast<const item_timeout &>(evt);
|
const auto &evt2 = dynamic_cast<const item_timeout &>(evt);
|
||||||
EXPECT_STREQ("/test_download_timeout.txt",
|
EXPECT_STREQ("/test_download_timeout.txt",
|
||||||
evt2.get_api_path().get<std::string>().c_str());
|
evt2.get_api_path().get<std::string>().c_str());
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "test_common.hpp"
|
#include "test_common.hpp"
|
||||||
|
|
||||||
#include "comm/curl/curl_comm.hpp"
|
#include "comm/curl/curl_comm.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "file_manager/file_manager.hpp"
|
#include "file_manager/file_manager.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/encrypt/encrypt_provider.hpp"
|
#include "providers/encrypt/encrypt_provider.hpp"
|
||||||
|
Reference in New Issue
Block a user