mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-02-09 09:23:56 +00:00
Fix the problem with redis not being initialized anymore.
This commit is contained in:
parent
60bc194848
commit
e44611301c
5 changed files with 29 additions and 10 deletions
|
@ -60,8 +60,9 @@ target_compile_definitions(${PROJECT_NAME}
|
||||||
PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1
|
PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1
|
||||||
PUBLIC $<$<CONFIG:Debug>:SPDLOG_DEBUG_ON>
|
PUBLIC $<$<CONFIG:Debug>:SPDLOG_DEBUG_ON>
|
||||||
PUBLIC $<$<CONFIG:Debug>:SPDLOG_TRACE_ON>
|
PUBLIC $<$<CONFIG:Debug>:SPDLOG_TRACE_ON>
|
||||||
PUBLIC tawashi_virtual_testing$<$<BOOL:BUILD_TESTING>:=virtual>
|
PUBLIC $<$<BOOL:${BUILD_TESTING}>:tawashi_virtual_testing=virtual>
|
||||||
PUBLIC $<$<BOOL:BUILD_TESTING>:TAWASHI_WITH_TESTING>
|
PUBLIC $<$<NOT:$<BOOL:${BUILD_TESTING}>>:tawashi_virtual_testing=>
|
||||||
|
PUBLIC $<$<BOOL:${BUILD_TESTING}>:TAWASHI_WITH_TESTING>
|
||||||
)
|
)
|
||||||
target_compile_options(${PROJECT_NAME}
|
target_compile_options(${PROJECT_NAME}
|
||||||
PRIVATE -fdiagnostics-color=always
|
PRIVATE -fdiagnostics-color=always
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace tawashi {
|
||||||
assert(not m_redis);
|
assert(not m_redis);
|
||||||
m_redis = std::make_unique<redis::IncRedis>(make_incredis(*m_settings));
|
m_redis = std::make_unique<redis::IncRedis>(make_incredis(*m_settings));
|
||||||
m_redis->connect();
|
m_redis->connect();
|
||||||
|
SPDLOG_TRACE(spdlog::get("statuslog"), "Trying to connect to Redis asynchronously");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Storage::is_connected() const {
|
bool Storage::is_connected() const {
|
||||||
|
@ -76,8 +77,9 @@ namespace tawashi {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Storage::finalize_connection() {
|
void Storage::finalize_connection() {
|
||||||
|
SPDLOG_TRACE(spdlog::get("statuslog"), "Asked Storage to finalize the Redis connection");
|
||||||
if (m_redis) {
|
if (m_redis) {
|
||||||
SPDLOG_TRACE(spdlog::get("statuslog"), "Finalizing redis connection");
|
SPDLOG_TRACE(spdlog::get("statuslog"), "Finalizing Redis connection");
|
||||||
m_redis->wait_for_connect();
|
m_redis->wait_for_connect();
|
||||||
auto batch = m_redis->make_batch();
|
auto batch = m_redis->make_batch();
|
||||||
batch.select(m_settings->as<uint32_t>("redis_db"));
|
batch.select(m_settings->as<uint32_t>("redis_db"));
|
||||||
|
|
|
@ -34,11 +34,6 @@ namespace tawashi {
|
||||||
const char g_post_key[] = "pastie";
|
const char g_post_key[] = "pastie";
|
||||||
const char g_language_key[] = "lang";
|
const char g_language_key[] = "lang";
|
||||||
const char g_duration_key[] = "ttl";
|
const char g_duration_key[] = "ttl";
|
||||||
#if defined(TAWASHI_WITH_TESTING)
|
|
||||||
const bool g_connect_to_redis = false;
|
|
||||||
#else
|
|
||||||
const bool g_connect_to_redis = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class MissingPostVarError : public TawashiException {
|
class MissingPostVarError : public TawashiException {
|
||||||
public:
|
public:
|
||||||
|
@ -78,12 +73,24 @@ namespace tawashi {
|
||||||
}
|
}
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
|
||||||
|
#if defined(TAWASHI_WITH_TESTING)
|
||||||
|
SubmitPasteResponse::SubmitPasteResponse (
|
||||||
|
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||||
|
std::ostream* parStreamOut,
|
||||||
|
const Kakoune::SafePtr<cgi::Env>& parCgiEnv,
|
||||||
|
bool parInitStorage
|
||||||
|
) :
|
||||||
|
Response(parSettings, parStreamOut, parCgiEnv, parInitStorage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SubmitPasteResponse::SubmitPasteResponse (
|
SubmitPasteResponse::SubmitPasteResponse (
|
||||||
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||||
std::ostream* parStreamOut,
|
std::ostream* parStreamOut,
|
||||||
const Kakoune::SafePtr<cgi::Env>& parCgiEnv
|
const Kakoune::SafePtr<cgi::Env>& parCgiEnv
|
||||||
) :
|
) :
|
||||||
Response(parSettings, parStreamOut, parCgiEnv, g_connect_to_redis)
|
Response(parSettings, parStreamOut, parCgiEnv, true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,15 @@
|
||||||
namespace tawashi {
|
namespace tawashi {
|
||||||
class SubmitPasteResponse : public Response {
|
class SubmitPasteResponse : public Response {
|
||||||
public:
|
public:
|
||||||
|
#if defined(TAWASHI_WITH_TESTING)
|
||||||
|
SubmitPasteResponse (
|
||||||
|
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||||
|
std::ostream* parStreamOut,
|
||||||
|
const Kakoune::SafePtr<cgi::Env>& parCgiEnv,
|
||||||
|
bool parInitStorage
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
SubmitPasteResponse (
|
SubmitPasteResponse (
|
||||||
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||||
std::ostream* parStreamOut,
|
std::ostream* parStreamOut,
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace tawashi {
|
||||||
const Kakoune::SafePtr<cgi::Env>& parCgiEnv,
|
const Kakoune::SafePtr<cgi::Env>& parCgiEnv,
|
||||||
std::string&& parPostData
|
std::string&& parPostData
|
||||||
) :
|
) :
|
||||||
SubmitPasteResponse(parSettings, parStreamOut, parCgiEnv),
|
SubmitPasteResponse(parSettings, parStreamOut, parCgiEnv, false),
|
||||||
m_fake_storage(parSettings, true),
|
m_fake_storage(parSettings, true),
|
||||||
m_post_data(std::move(parPostData))
|
m_post_data(std::move(parPostData))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue