Skip to content

Commit 99a18b9

Browse files
authored
issue 101: support dynamic config (#105)
1 parent 0684dd8 commit 99a18b9

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HomeBlocksConan(ConanFile):
1111
name = "homeblocks"
12-
version = "1.0.21"
12+
version = "1.0.22"
1313
homepage = "https://github.com/eBay/HomeBlocks"
1414
description = "Block Store built on HomeStore"
1515
topics = ("ebay")

src/lib/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ cmake_minimum_required (VERSION 3.11)
22

33
add_flags("-Wno-unused-parameter")
44

5+
list(GET sisl_INCLUDE_DIRS 0 SISL_TOP_INCLUDE)
6+
include ("${SISL_TOP_INCLUDE}/../cmake/settings_gen.cmake")
7+
8+
if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
9+
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
10+
endif()
11+
512
add_library(${PROJECT_NAME}_core OBJECT)
613
target_sources(${PROJECT_NAME}_core PRIVATE
714
homeblks_impl.cpp
@@ -13,6 +20,14 @@ target_link_libraries(${PROJECT_NAME}_core
1320
${COMMON_DEPS}
1421
)
1522

23+
set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_INCLUDE_DIRS}/../bin/flatc)
24+
settings_gen_cpp(
25+
${FLATBUFFERS_FLATC_EXECUTABLE}
26+
${CMAKE_CURRENT_BINARY_DIR}/generated/
27+
"${PROJECT_NAME}_core"
28+
home_blks_config.fbs
29+
)
30+
1631
#add_subdirectory(homestore_backend)
1732
#add_subdirectory(memory_backend)
1833
add_subdirectory(volume)

src/lib/home_blks_config.fbs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
native_include "sisl/utility/non_null_ptr.hpp";
2+
3+
namespace homeblkscfg;
4+
5+
attribute "hotswap";
6+
attribute "deprecated";
7+
8+
9+
table HomeBlksSettings{
10+
// reaper thread timer in seconds
11+
reaper_thread_timer_secs: uint64 = 120;
12+
}
13+
14+
root_type HomeBlksSettings;

src/lib/home_blks_config.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <sisl/settings/settings.hpp>
4+
#include "generated/home_blks_config_generated.h"
5+
6+
SETTINGS_INIT(homeblkscfg::HomeBlksSettings, home_blks_config);
7+
8+
namespace homeblocks {
9+
#define HB_DYNAMIC_CONFIG_WITH(...) SETTINGS(home_blks_config, __VA_ARGS__)
10+
#define HB_DYNAMIC_CONFIG_THIS(...) SETTINGS_THIS(home_blks_config, __VA_ARGS__)
11+
#define HB_DYNAMIC_CONFIG(...) SETTINGS_VALUE(home_blks_config, __VA_ARGS__)
12+
13+
#define HB_SETTINGS_FACTORY() SETTINGS_FACTORY(home_blks_config)
14+
15+
} // namespace homeblocks

src/lib/homeblks_impl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <sisl/options/options.h>
2323
#include "homeblks_impl.hpp"
2424
#include "listener.hpp"
25+
#include "home_blks_config.hpp"
2526

2627
SISL_OPTION_GROUP(homeblocks,
2728
(executor_type, "", "executor", "Executor to use for Future deferal",
@@ -32,7 +33,7 @@ SISL_LOGGING_DEF(HOMEBLOCKS_LOG_MODS)
3233
namespace homeblocks {
3334

3435
extern std::shared_ptr< HomeBlocks > init_homeblocks(std::weak_ptr< HomeBlocksApplication >&& application) {
35-
LOGI("Initializing HomeBlocks");
36+
LOGI("Initializing HomeBlocks with reaper thread timer: {} seconds", HB_DYNAMIC_CONFIG(reaper_thread_timer_secs));
3637
auto inst = std::make_shared< HomeBlocksImpl >(std::move(application));
3738
inst->init_homestore();
3839
inst->init_cp();

0 commit comments

Comments
 (0)