BuildCache
configuration.hpp
1 //--------------------------------------------------------------------------------------------------
2 // Copyright (c) 2018 Marcus Geelnard
3 //
4 // This software is provided 'as-is', without any express or implied warranty. In no event will the
5 // authors be held liable for any damages arising from the use of this software.
6 //
7 // Permission is granted to anyone to use this software for any purpose, including commercial
8 // applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 //
10 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote
11 // the original software. If you use this software in a product, an acknowledgment in the
12 // product documentation would be appreciated but is not required.
13 //
14 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
15 // being the original software.
16 //
17 // 3. This notice may not be removed or altered from any source distribution.
18 //--------------------------------------------------------------------------------------------------
19 
20 #ifndef BUILDCACHE_CONFIGURATION_HPP_
21 #define BUILDCACHE_CONFIGURATION_HPP_
22 
23 #include <base/string_list.hpp>
24 
25 #include <cstdint>
26 
27 #include <map>
28 #include <string>
29 
30 namespace bcache {
31 namespace config {
32 
34 enum class cache_accuracy_t {
35  SLOPPY,
36  DEFAULT,
37  STRICT
38 };
39 
41 enum class compress_format_t {
42  LZ4,
43  ZSTD,
44  DEFAULT
45 };
46 
50 std::string to_string(const cache_accuracy_t accuracy);
51 
55 std::string to_string(const compress_format_t format);
56 
58 void init();
59 
61 const std::string& config_file();
62 
65 
67 bool cache_link_commands();
68 
70 bool compress();
71 
74 
76 int32_t compress_level();
77 
79 int32_t debug();
80 
82 const std::string& dir();
83 
85 bool direct_mode();
86 
88 bool disable();
89 
91 bool hard_links();
92 
95 
97 const std::string& impersonate();
98 
100 const std::string& log_file();
101 
103 const string_list_t& lua_paths();
104 
106 int64_t max_cache_size();
107 
109 int64_t max_local_entry_size();
110 
112 int64_t max_remote_entry_size();
113 
115 bool perf();
116 
118 const std::string& prefix();
119 
121 bool read_only();
122 
124 bool read_only_remote();
125 
127 const std::string& remote();
128 
130 bool remote_locks();
131 
133 const std::string& s3_access();
134 
136 const std::string& s3_secret();
137 
139 bool terminate_on_miss();
140 
141 } // namespace config
142 } // namespace bcache
143 
144 #endif // BUILDCACHE_CONFIGURATION_HPP_
bcache::config::max_local_entry_size
int64_t max_local_entry_size()
Definition: configuration.cpp:652
bcache::config::compress_format_t
compress_format_t
The compression format.
Definition: configuration.hpp:41
bcache::config::remote_locks
bool remote_locks()
Definition: configuration.cpp:680
bcache::config::cache_accuracy_t::DEFAULT
@ DEFAULT
For most users.
bcache::config::terminate_on_miss
bool terminate_on_miss()
Definition: configuration.cpp:692
bcache::config::max_cache_size
int64_t max_cache_size()
Definition: configuration.cpp:648
bcache::config::cache_accuracy_t::STRICT
@ STRICT
Be as strict as possible.
bcache::config::compress_level
int32_t compress_level()
Definition: configuration.cpp:608
bcache::config::init
void init()
Initialize the configuration based on environment variables etc.
Definition: configuration.cpp:365
bcache::config::compress_format_t::DEFAULT
@ DEFAULT
Utilize LZ4 compression.
bcache::config::log_file
const std::string & log_file()
Definition: configuration.cpp:640
bcache
The top level namespace.
Definition: compressor.cpp:34
bcache::string_list_t
A convenient vector of strings container with support functions for program argument handling.
Definition: string_list.hpp:30
bcache::config::accuracy
cache_accuracy_t accuracy()
Definition: configuration.cpp:592
bcache::config::s3_access
const std::string & s3_access()
Definition: configuration.cpp:684
bcache::config::to_string
std::string to_string(const cache_accuracy_t accuracy)
Convert a cache accuracy enum value to a string.
Definition: configuration.cpp:339
bcache::config::lua_paths
const string_list_t & lua_paths()
Definition: configuration.cpp:644
bcache::config::read_only_remote
bool read_only_remote()
Definition: configuration.cpp:672
bcache::config::config_file
const std::string & config_file()
Definition: configuration.cpp:588
bcache::config::cache_accuracy_t::SLOPPY
@ SLOPPY
Maximize cache hit ratio, but may produce incorrect results for certain use cases.
bcache::config::direct_mode
bool direct_mode()
Definition: configuration.cpp:620
bcache::config::impersonate
const std::string & impersonate()
Definition: configuration.cpp:636
bcache::config::remote
const std::string & remote()
Definition: configuration.cpp:676
bcache::config::cache_accuracy_t
cache_accuracy_t
The cache accuracy.
Definition: configuration.hpp:34
bcache::config::cache_link_commands
bool cache_link_commands()
Definition: configuration.cpp:596
bcache::config::compress
bool compress()
Definition: configuration.cpp:600
bcache::config::disable
bool disable()
Definition: configuration.cpp:624
bcache::config::s3_secret
const std::string & s3_secret()
Definition: configuration.cpp:688
bcache::config::compress_format_t::ZSTD
@ ZSTD
Utilize ZSTD compression (slower compression, smaller cache sizes)
bcache::config::max_remote_entry_size
int64_t max_remote_entry_size()
Definition: configuration.cpp:656
bcache::config::compress_format
compress_format_t compress_format()
Definition: configuration.cpp:604
bcache::config::read_only
bool read_only()
Definition: configuration.cpp:668
bcache::config::perf
bool perf()
Definition: configuration.cpp:660
bcache::config::hard_links
bool hard_links()
Definition: configuration.cpp:628
bcache::config::prefix
const std::string & prefix()
Definition: configuration.cpp:664
bcache::config::dir
const std::string & dir()
Definition: configuration.cpp:616
bcache::config::hash_extra_files
string_list_t hash_extra_files()
Definition: configuration.cpp:632
bcache::config::debug
int32_t debug()
Definition: configuration.cpp:612
bcache::config::compress_format_t::LZ4
@ LZ4
Utilize LZ4 compression (faster compression, larger cache sizes)