Lay out initial parts for the Storage framework

This includes a manager, component manager, BIF and script code, and
parts to support new storage backend plugins.
This commit is contained in:
Tim Wojtulewicz 2023-09-11 12:21:58 -07:00
parent 3d6e7c85b0
commit 2ea0f3e70a
32 changed files with 874 additions and 1 deletions

52
src/storage/Manager.h Normal file
View file

@ -0,0 +1,52 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/plugin/ComponentManager.h"
#include "zeek/storage/Backend.h"
#include "zeek/storage/Component.h"
namespace zeek::storage {
class Manager final : public plugin::ComponentManager<Component> {
public:
Manager();
~Manager() = default;
/**
* Initialization of the manager. This is called late during Zeek's
* initialization after any scripts are processed.
*/
void InitPostScript();
/**
* Opens a new storage backend.
*
* @param type The tag for the type of backend being opened.
* @param options A record val representing the configuration for this
* type of backend.
* @return A pair containing a pointer to a backend and a string for
* returning error messages if needed.
*/
zeek::expected<BackendPtr, std::string> OpenBackend(const Tag& type, RecordValPtr options);
/**
* Closes a storage backend.
*/
void CloseBackend(BackendPtr backend);
// TODO:
// - Hooks for storage-backed tables?
// - Handling aggregation from workers on a single manager?
private:
std::vector<BackendPtr> backends;
};
} // namespace zeek::storage
namespace zeek {
extern storage::Manager* storage_mgr;
} // namespace zeek