Ground work for pluggable storage serializers

This commit is contained in:
Tim Wojtulewicz 2025-04-01 16:14:35 -07:00
parent faac36f4cd
commit e545fe8256
21 changed files with 235 additions and 57 deletions

View file

@ -10,6 +10,7 @@
#include "zeek/plugin/ComponentManager.h"
#include "zeek/storage/Backend.h"
#include "zeek/storage/Component.h"
#include "zeek/storage/Serializer.h"
namespace zeek::storage {
@ -24,7 +25,7 @@ public:
} // namespace detail
class Manager final : public plugin::ComponentManager<Component> {
class Manager final {
public:
Manager();
~Manager();
@ -43,7 +44,16 @@ public:
* @return A std::expected containing either a valid BackendPtr with the result of the
* operation or a string containing an error message for failure.
*/
zeek::expected<BackendPtr, std::string> Instantiate(const Tag& type);
zeek::expected<BackendPtr, std::string> InstantiateBackend(const Tag& type);
/**
* Instantiates a new serializer object.
*
* @param type The tag for the type of backend being opened.
* @return A std::expected containing either a valid BackendPtr with the result of the
* operation or a string containing an error message for failure.
*/
zeek::expected<std::unique_ptr<Serializer>, std::string> InstantiateSerializer(const Tag& type);
/**
* Opens a new storage backend.
@ -82,6 +92,9 @@ public:
*/
void Expire(double t);
plugin::ComponentManager<BackendComponent>& BackendMgr() { return backend_mgr; }
plugin::ComponentManager<SerializerComponent>& SerializerMgr() { return serializer_mgr; }
protected:
friend class storage::detail::ExpirationTimer;
void RunExpireThread();
@ -94,6 +107,9 @@ protected:
private:
std::vector<BackendPtr> backends;
std::mutex backends_mtx;
plugin::ComponentManager<BackendComponent> backend_mgr;
plugin::ComponentManager<SerializerComponent> serializer_mgr;
};
} // namespace zeek::storage