mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Add infrastructure for automated expiration of storage entries
This is used for backends that don't support expiration natively.
This commit is contained in:
parent
8dee733a7d
commit
d07d27453a
12 changed files with 96 additions and 21 deletions
|
@ -2,12 +2,26 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "zeek/Timer.h"
|
||||
#include "zeek/plugin/ComponentManager.h"
|
||||
#include "zeek/storage/Backend.h"
|
||||
#include "zeek/storage/Component.h"
|
||||
|
||||
namespace zeek::storage {
|
||||
|
||||
namespace detail {
|
||||
|
||||
class ExpirationTimer final : public zeek::detail::Timer {
|
||||
public:
|
||||
ExpirationTimer(double t) : zeek::detail::Timer(t, zeek::detail::TIMER_STORAGE_EXPIRE) {}
|
||||
~ExpirationTimer() override {}
|
||||
void Dispatch(double t, bool is_expire) override;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class Manager final : public plugin::ComponentManager<Component> {
|
||||
public:
|
||||
Manager();
|
||||
|
@ -40,12 +54,14 @@ public:
|
|||
*/
|
||||
void CloseBackend(BackendPtr backend);
|
||||
|
||||
// TODO:
|
||||
// - Hooks for storage-backed tables?
|
||||
// - Handling aggregation from workers on a single manager?
|
||||
protected:
|
||||
friend class storage::detail::ExpirationTimer;
|
||||
void Expire();
|
||||
void StartExpirationTimer();
|
||||
|
||||
private:
|
||||
std::vector<BackendPtr> backends;
|
||||
std::mutex backends_mtx;
|
||||
};
|
||||
|
||||
} // namespace zeek::storage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue