Skip to content

Commit 57e1655

Browse files
authored
status_server: Support new probe http api /tiflash/livez and /tiflash/readyz (#10504)
close #10496 * Support returning non 200 response body from FFI function to status server * Support new probe http api `/tiflash/livez` and `/tiflash/readyz` * `/tiflash/livez` always return response code 200 * `/tiflash/readyz` will - return response code 200 when it is ready for serving coprocessor requests - return response code 500 when it is not ready Signed-off-by: JaySon-Huang <tshent@qq.com>
1 parent d8af028 commit 57e1655

9 files changed

Lines changed: 321 additions & 180 deletions

File tree

contrib/tiflash-proxy-next-gen

dbms/src/Common/FailPoint.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ namespace DB
7575
M(exception_build_local_index_for_file) \
7676
M(force_not_support_local_index) \
7777
M(sync_schema_request_failure) \
78-
M(force_set_lifecycle_resp)
78+
M(force_set_lifecycle_resp) \
79+
M(force_return_store_status)
7980

8081
#define APPLY_FOR_FAILPOINTS(M) \
8182
M(skip_check_segment_update) \

dbms/src/Storages/KVStore/FFI/ProxyFFI.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,44 @@ RawCppPtr GenRawCppPtr(RawVoidPtr ptr_, RawCppPtrTypeImpl type_)
896896
return RawCppPtr{ptr_, static_cast<RawCppPtrType>(type_)};
897897
}
898898

899+
CppStrWithView GenCppStrWithView(std::string && str)
900+
{
901+
if (str.empty())
902+
{
903+
return CppStrWithView{
904+
.inner = GenRawCppPtr(),
905+
.view = BaseBuffView{nullptr, 0},
906+
};
907+
}
908+
// Generate a raw cpp string ptr
909+
auto * str_ptr = RawCppString::New(str);
910+
// Wrap and return. The rust side will own the raw cpp string ptr.
911+
// When rust side drops it, it will call `GcRawCppPtr` to free the memory.
912+
return CppStrWithView{
913+
.inner = GenRawCppPtr(str_ptr, RawCppPtrTypeImpl::String),
914+
.view = BaseBuffView{str_ptr->data(), str_ptr->size()},
915+
};
916+
}
917+
918+
CppStrWithView GenCppStrWithView(const std::string & str)
919+
{
920+
if (str.empty())
921+
{
922+
return CppStrWithView{
923+
.inner = GenRawCppPtr(),
924+
.view = BaseBuffView{nullptr, 0},
925+
};
926+
}
927+
// Generate a raw cpp string ptr
928+
auto * str_ptr = RawCppString::New(str);
929+
// Wrap and return. The rust side will own the raw cpp string ptr.
930+
// When rust side drops it, it will call `GcRawCppPtr` to free the memory.
931+
return CppStrWithView{
932+
.inner = GenRawCppPtr(str_ptr, RawCppPtrTypeImpl::String),
933+
.view = BaseBuffView{str_ptr->data(), str_ptr->size()},
934+
};
935+
}
936+
899937
CppStrWithView GetConfig(EngineStoreServerWrap * server, [[maybe_unused]] uint8_t full)
900938
{
901939
std::string config_file_path;
@@ -908,7 +946,7 @@ CppStrWithView GetConfig(EngineStoreServerWrap * server, [[maybe_unused]] uint8_
908946
return CppStrWithView{.inner = GenRawCppPtr(), .view = BaseBuffView{nullptr, 0}};
909947
auto * s = RawCppString::New((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
910948
stream.close();
911-
/** the returned str must be formated as TOML, proxy will parse and show in form of JASON.
949+
/** the returned str must be formatted as TOML, proxy will parse and show in form of JSON.
912950
* curl `http://{status-addr}/config`, got:
913951
* {"raftstore-proxy":xxxx,"engine-store":xxx}
914952
*

dbms/src/Storages/KVStore/FFI/ProxyFFI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ enum class RawCppPtrTypeImpl : RawCppPtrType
6767

6868
RawCppPtr GenRawCppPtr(RawVoidPtr ptr_ = nullptr, RawCppPtrTypeImpl type_ = RawCppPtrTypeImpl::None);
6969

70+
CppStrWithView GenCppStrWithView(std::string && str);
71+
CppStrWithView GenCppStrWithView(const std::string & str);
72+
7073
struct ReadIndexTask;
7174
struct RawRustPtrWrap;
7275

0 commit comments

Comments
 (0)