From 6f3c7b6f5671ca3131effd3ab878a2cc4c54fb09 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 5 Sep 2018 00:01:39 -0700 Subject: [PATCH] modules/media: Fix init ordering and decls. --- modules/media/media.cc | 120 ++++++++++++++++++++--------------------- modules/media/media.h | 4 ++ 2 files changed, 64 insertions(+), 60 deletions(-) diff --git a/modules/media/media.cc b/modules/media/media.cc index 02e6c6849..a81ea10df 100644 --- a/modules/media/media.cc +++ b/modules/media/media.cc @@ -10,66 +10,6 @@ #include "media.h" -conf::item -media_blocks_cache_size -{ - { - { "name", "ircd.media.blocks.cache.size" }, - { "default", long(48_MiB) }, - }, [] - { - const size_t &value{media_blocks_cache_size}; - db::capacity(db::cache(blocks), value); - } -}; - -conf::item -media_blocks_cache_comp_size -{ - { - { "name", "ircd.media.blocks.cache_comp.size" }, - { "default", long(16_MiB) }, - }, [] - { - const size_t &value{media_blocks_cache_comp_size}; - db::capacity(db::cache_compressed(blocks), value); - } -}; - -// Blocks column -const db::database::descriptor -media_blocks_descriptor -{ - // name - "blocks", - - // explain - R"( - Key-value store of blocks belonging to files. The key is a hash of - the block. The key is plaintext sha256-b58 and the block is binary - up to 32768 bytes. - )", - - // typing - { - typeid(string_view), typeid(string_view) - }, - - {}, // options - {}, // comparaor - {}, // prefix transform - -1, // cache size (uses conf item) - -1, // compressed cache size (uses conf item) -}; - -const db::database::description -media_description -{ - { "default" }, // requirement of RocksDB - - media_blocks_descriptor, -}; - mapi::header IRCD_MODULE { @@ -96,12 +36,72 @@ media_log "media" }; +// Blocks column +decltype(media_blocks_descriptor) +media_blocks_descriptor +{ + // name + "blocks", + + // explain + R"( + Key-value store of blocks belonging to files. The key is a hash of + the block. The key is plaintext sha256-b58 and the block is binary + up to 32768 bytes. + )", + + // typing + { + typeid(string_view), typeid(string_view) + }, + + {}, // options + {}, // comparaor + {}, // prefix transform + -1, // cache size (uses conf item) + -1, // compressed cache size (uses conf item) +}; + +decltype(media_description) +media_description +{ + { "default" }, // requirement of RocksDB + + media_blocks_descriptor, +}; + decltype(media) media; decltype(blocks) blocks; +decltype(media_blocks_cache_size) +media_blocks_cache_size +{ + { + { "name", "ircd.media.blocks.cache.size" }, + { "default", long(48_MiB) }, + }, [] + { + const size_t &value{media_blocks_cache_size}; + db::capacity(db::cache(blocks), value); + } +}; + +decltype(media_blocks_cache_comp_size) +media_blocks_cache_comp_size +{ + { + { "name", "ircd.media.blocks.cache_comp.size" }, + { "default", long(16_MiB) }, + }, [] + { + const size_t &value{media_blocks_cache_comp_size}; + db::capacity(db::cache_compressed(blocks), value); + } +}; + std::set downloading; diff --git a/modules/media/media.h b/modules/media/media.h index 94c01f3f0..63ebf14dc 100644 --- a/modules/media/media.h +++ b/modules/media/media.h @@ -12,6 +12,10 @@ using namespace ircd; extern mapi::header IRCD_MODULE; extern log::log media_log; +extern conf::item media_blocks_cache_size; +extern conf::item media_blocks_cache_comp_size; +extern const db::database::descriptor media_blocks_descriptor; +extern const db::database::description media_description; extern std::shared_ptr media; extern db::column blocks;