14 : client_(ipc::IpcClient::create_socket(socket_path))
17 throw std::runtime_error(
"Failed to connect to server at " + socket_path);
32 auto wrapped = std::make_tuple(
std::move(command));
35 msgpack::sbuffer send_buffer;
36 msgpack::pack(send_buffer, wrapped);
39 constexpr uint64_t timeout_ns = 30'000'000'000ULL;
40 if (!
client_->send(send_buffer.data(), send_buffer.size(), timeout_ns)) {
41 throw std::runtime_error(
"Failed to send command to server");
45 auto response_span =
client_->receive(timeout_ns);
46 if (response_span.empty()) {
47 throw std::runtime_error(
"Empty response from server");
51 auto unpacked = msgpack::unpack(
reinterpret_cast<const char*
>(response_span.data()), response_span.size());
52 auto response_obj = unpacked.get();
55 response_obj.convert(response);
58 client_->release(response_span.size());
61 return std::move(response).
visit([](
auto&& resp) ->
typename Cmd::Response {
65 throw std::runtime_error(
"Server error: " + resp.message);
69 throw std::runtime_error(
"Unexpected response type from server");
A wrapper around std::variant that provides msgpack serialization based on type names.
decltype(auto) visit(Visitor &&vis) &&
Cmd::Response send(Cmd &&cmd) const
std::unique_ptr< ipc::IpcClient > client_
void delete_fork(WsdbDeleteFork cmd)
void create_checkpoint(WsdbCreateCheckpoint cmd)
WsdbGetSiblingPath::Response get_sibling_path(WsdbGetSiblingPath cmd) const
WsdbCommit::Response commit()
WsdbGetBlockNumbersForLeafIndices::Response get_block_numbers_for_leaf_indices(WsdbGetBlockNumbersForLeafIndices cmd) const
WsdbBatchInsert::Response batch_insert(WsdbBatchInsert cmd) const
void copy_stores(WsdbCopyStores cmd) const
WsdbCreateFork::Response create_fork(WsdbCreateFork cmd)
void update_archive(WsdbUpdateArchive cmd) const
WsdbRemoveHistoricalBlocks::Response remove_historical_blocks(WsdbRemoveHistoricalBlocks cmd) const
WsdbUnwindBlocks::Response unwind_blocks(WsdbUnwindBlocks cmd)
void commit_checkpoint(WsdbCommitCheckpoint cmd)
WsdbFindLeafIndices::Response find_leaf_indices(WsdbFindLeafIndices cmd) const
WsdbFinalizeBlocks::Response finalize_blocks(WsdbFinalizeBlocks cmd) const
WsdbFindSiblingPaths::Response find_sibling_paths(WsdbFindSiblingPaths cmd) const
WsdbGetInitialStateReference::Response get_initial_state_reference() const
WsdbGetTreeInfo::Response get_tree_info(WsdbGetTreeInfo cmd) const
WsdbSyncBlock::Response sync_block(WsdbSyncBlock cmd)
WsdbSequentialInsert::Response sequential_insert(WsdbSequentialInsert cmd) const
WsdbIpcClient(const std::string &socket_path)
void commit_all_checkpoints(WsdbCommitAllCheckpoints cmd)
WsdbGetLeafValue::Response get_leaf_value(WsdbGetLeafValue cmd) const
void revert_checkpoint(WsdbRevertCheckpoint cmd)
WsdbGetStateReference::Response get_state_reference(WsdbGetStateReference cmd) const
WsdbFindLowLeaf::Response find_low_leaf(WsdbFindLowLeaf cmd) const
void append_leaves(WsdbAppendLeaves cmd) const
WsdbGetLeafPreimage::Response get_leaf_preimage(WsdbGetLeafPreimage cmd) const
WsdbGetStatus::Response get_status() const
void revert_all_checkpoints(WsdbRevertAllCheckpoints cmd)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
WsdbCommand NamedUnion, WsdbRequest context, and dispatch function.