NetworkedApplications: serve KvApi behind a real Net HTTP listener
This commit is contained in:
1 parent
fd763e4feb
commit
183b8033fd
4 files changed
+204
-1
No files matched your search
@@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "networked_kv/domain.hpp"
|
||||
#include "networked_kv/http_api.hpp"
|
||||
|
||||
#include <Void/Functional/Result.hpp>
|
||||
#include <Void/Net/HttpServer.hpp>
|
||||
#include <Void/Runtime/Host.hpp>
|
||||
|
||||
#include <chrono>
|
||||
@@ -16,6 +20,8 @@ namespace NetworkedKv
|
||||
struct NetworkedConfig {
|
||||
std::string listen_address{"127.0.0.1:0"};
|
||||
std::string admin_address{};
|
||||
/// Bearer token required on the data plane; empty fails closed.
|
||||
std::string bearer_token{};
|
||||
std::uint32_t max_connections{64};
|
||||
std::size_t max_request_bytes{1024ULL * 1024ULL};
|
||||
std::size_t max_scan_page{1000};
|
||||
@@ -52,6 +58,7 @@ namespace NetworkedKv
|
||||
bool ready{false};
|
||||
bool managed{false};
|
||||
std::size_t started_workers{0};
|
||||
std::uint16_t bound_port{0};
|
||||
};
|
||||
|
||||
/// Composition surface for the networked key-value reference service.
|
||||
@@ -86,6 +93,8 @@ namespace NetworkedKv
|
||||
{
|
||||
return m_config;
|
||||
}
|
||||
/// Port the HTTP listener actually bound (0 when not listening).
|
||||
[[nodiscard]] std::uint16_t bound_port() const noexcept;
|
||||
|
||||
private:
|
||||
|
||||
@@ -96,6 +105,10 @@ namespace NetworkedKv
|
||||
ApplicationResources m_resources{};
|
||||
std::unique_ptr<Void::Runtime::Host> m_owned_host{};
|
||||
Void::Runtime::Host* m_host{nullptr};
|
||||
// Heap-owned so a moved application keeps the KvApi reference valid.
|
||||
std::unique_ptr<MemoryKvStore> m_store{};
|
||||
std::unique_ptr<KvApi> m_api{};
|
||||
std::unique_ptr<Void::Net::HttpServer> m_server{};
|
||||
ApplicationState m_state{ApplicationState::Created};
|
||||
};
|
||||
} // namespace NetworkedKv
|
||||
Reference in new issue
Block a user