LCOV - code coverage report
Current view: top level - source/extensions/key_value/file_based - config.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 5 5 100.0 %
Date: 2024-01-05 06:35:25 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/common/key_value_store.h"
       4             : #include "envoy/config/common/key_value/v3/config.pb.h"
       5             : #include "envoy/config/common/key_value/v3/config.pb.validate.h"
       6             : #include "envoy/extensions/key_value/file_based/v3/config.pb.h"
       7             : #include "envoy/extensions/key_value/file_based/v3/config.pb.validate.h"
       8             : 
       9             : #include "source/common/common/key_value_store_base.h"
      10             : 
      11             : namespace Envoy {
      12             : namespace Extensions {
      13             : namespace KeyValue {
      14             : 
      15             : // A filesystem based key value store, which loads from and flushes to the file
      16             : // provided.
      17             : //
      18             : // All keys and values are flushed to a single file as
      19             : // [length]\n[key][length]\n[value]
      20             : class FileBasedKeyValueStore : public KeyValueStoreBase {
      21             : public:
      22             :   FileBasedKeyValueStore(Event::Dispatcher& dispatcher, std::chrono::milliseconds flush_interval,
      23             :                          Filesystem::Instance& file_system, const std::string& filename,
      24             :                          uint32_t max_entries);
      25             :   // KeyValueStore
      26             :   void flush() override;
      27             : 
      28             : private:
      29             :   Filesystem::Instance& file_system_;
      30             :   const std::string filename_;
      31             : };
      32             : 
      33             : class FileBasedKeyValueStoreFactory : public KeyValueStoreFactory {
      34             : public:
      35             :   // KeyValueStoreFactory
      36             :   KeyValueStorePtr createStore(const Protobuf::Message& config,
      37             :                                ProtobufMessage::ValidationVisitor& validation_visitor,
      38             :                                Event::Dispatcher& dispatcher,
      39             :                                Filesystem::Instance& file_system) override;
      40             : 
      41             :   // TypedFactory
      42           1 :   ProtobufTypes::MessagePtr createEmptyConfigProto() override {
      43           1 :     return ProtobufTypes::MessagePtr{
      44           1 :         new envoy::extensions::key_value::file_based::v3::FileBasedKeyValueStoreConfig()};
      45           1 :   }
      46             : 
      47          38 :   std::string name() const override { return "envoy.key_value.file_based"; }
      48             : };
      49             : 
      50             : } // namespace KeyValue
      51             : } // namespace Extensions
      52             : } // namespace Envoy

Generated by: LCOV version 1.15