Consume Void::Net directly in NetworkClient and callers

Delete NetworkClient's to_void_method/to_void_proxy/to_api_response bridge
and the Api::RetryConfig member; the client builds Void::Net::Request, sends
via Void::Net::HttpClient, returns Void::Net::Response, and retries via an
internal Void::Retry policy + retryable-status list.

Call sites updated to Void::Net member names: isSuccess()->ok(),
statusCode->status, getHeader()->header() (optional<string_view>),
isRedirect()->status range check; proxy isValid()->enabled(),
requiresAuth()->has_auth(), isSocks5()->kind == Kind::Socks5. Proxy fields
flow through YtDlpManager/AudioDecoder/MusicManager unchanged in spelling.
On-disk proxy shape is now Void::Net::ProxyConfig (kind: None/Http/Socks5);
config.example.json updated and proxy round-trip verified. Build green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-23 13:49:26 +03:00
1 parent 3af9aecbec
commit 9d56a6ff01
12 files changed
+158 -223

No files matched your search

+2 -2
View File
@@ -60,7 +60,7 @@ namespace Echoion::Core
void setOutputFormat(uint32_t sampleRate, uint32_t channels);
// Set proxy configuration for network requests
void setProxyConfig(const std::optional<Api::ProxyConfig>& proxy);
void setProxyConfig(const std::optional<Void::Net::ProxyConfig>& proxy);
// Hardware acceleration
[[nodiscard]] bool isHardwareAccelerated() const
@@ -159,7 +159,7 @@ namespace Echoion::Core
std::string currentUrl_;
std::atomic<uint32_t> streamSampleRate_{48000};
std::optional<Api::ProxyConfig> proxyConfig_;
std::optional<Void::Net::ProxyConfig> proxyConfig_;
// Statistics
mutable std::mutex statsMutex_;
+49 -35
View File
@@ -1,11 +1,12 @@
#pragma once
#include <NetworkInterface.hpp>
#include <NetworkTypes.hpp>
#include <Types.hpp>
#include <Void/Async/ThreadPool.hpp>
#include <Void/Data/Json.hpp>
#include <Void/Data/Reflect.hpp>
#include <Void/Functional/Retry.hpp>
#include <Void/Net/Http.hpp>
#include <atomic>
#include <format>
#include <future>
@@ -19,7 +20,8 @@ namespace Echoion::Core
// HTTP client implementing Api::INetworkClient. A thin adapter over
// Void::Net::HttpClient (HTTP/HTTPS, TLS, SOCKS5 + HTTP-CONNECT proxies);
// retry/backoff is layered here via Void::Retry.
// retry/backoff is layered here via Void::Retry. Speaks Void::Net types
// directly — no echoion-side HTTP mirror.
class NetworkClient : public Api::INetworkClient
{
public:
@@ -28,50 +30,54 @@ namespace Echoion::Core
~NetworkClient() override;
Api::Result<void> initialize(
const std::optional<Api::ProxyConfig>& proxy = std::nullopt);
void shutdown();
const std::optional<Void::Net::ProxyConfig>& proxy =
std::nullopt) override;
void shutdown() override;
// Synchronous requests
[[nodiscard]] Api::Result<Api::HttpResponse>
[[nodiscard]] Api::Result<Void::Net::Response>
get(std::string_view url,
const std::vector<Api::HttpHeader>& headers = {});
[[nodiscard]] Api::Result<Api::HttpResponse>
const std::vector<Void::Net::Header>& headers = {}) override;
[[nodiscard]] Api::Result<Void::Net::Response>
post(std::string_view url, std::string_view body,
const std::vector<Api::HttpHeader>& headers = {});
[[nodiscard]] Api::Result<Api::HttpResponse>
request(const Api::HttpRequest& req);
const std::vector<Void::Net::Header>& headers = {})
override;
[[nodiscard]] Api::Result<Void::Net::Response>
request(const Void::Net::Request& req) override;
// Asynchronous requests
[[nodiscard]] std::future<Api::Result<Api::HttpResponse>>
[[nodiscard]] std::future<Api::Result<Void::Net::Response>>
getAsync(std::string_view url,
const std::vector<Api::HttpHeader>& headers = {});
[[nodiscard]] std::future<Api::Result<Api::HttpResponse>>
const std::vector<Void::Net::Header>& headers = {})
override;
[[nodiscard]] std::future<Api::Result<Void::Net::Response>>
postAsync(std::string_view url, std::string_view body,
const std::vector<Api::HttpHeader>& headers = {});
[[nodiscard]] std::future<Api::Result<Api::HttpResponse>>
requestAsync(const Api::HttpRequest& req);
const std::vector<Void::Net::Header>& headers = {})
override;
[[nodiscard]] std::future<Api::Result<Void::Net::Response>>
requestAsync(const Void::Net::Request& req) override;
// Concurrent batch requests
[[nodiscard]] std::vector<Api::Result<Api::HttpResponse>>
requestBatch(const std::vector<Api::HttpRequest>& requests);
[[nodiscard]] std::vector<Api::Result<Void::Net::Response>>
requestBatch(const std::vector<Void::Net::Request>& requests);
// JSON helpers using Void::Json reflection
template <typename T>
[[nodiscard]] Api::Result<T>
getJson(std::string_view url,
const std::vector<Api::HttpHeader>& headers = {})
const std::vector<Void::Net::Header>& headers = {})
{
auto response = get(url, headers);
if (!response) {
return std::unexpected(response.error());
}
return parseJson<T>(response->bodyAsString());
return parseJson<T>(response->body);
}
template <typename T, typename Body>
[[nodiscard]] Api::Result<T>
postJson(std::string_view url, const Body& body,
const std::vector<Api::HttpHeader>& headers = {})
const std::vector<Void::Net::Header>& headers = {})
{
std::string jsonBody =
Void::Json::serialize(Void::Json::to_json(body));
@@ -79,17 +85,15 @@ namespace Echoion::Core
if (!response) {
return std::unexpected(response.error());
}
return parseJson<T>(response->bodyAsString());
return parseJson<T>(response->body);
}
// Proxy configuration
void setProxy(const std::optional<Api::ProxyConfig>& proxy);
[[nodiscard]] std::optional<Api::ProxyConfig> getProxy() const;
void clearProxy();
// Retry configuration
void setRetryConfig(const Api::RetryConfig& config);
[[nodiscard]] Api::RetryConfig getRetryConfig() const;
void setProxy(
const std::optional<Void::Net::ProxyConfig>& proxy) override;
[[nodiscard]] std::optional<Void::Net::ProxyConfig>
getProxy() const override;
void clearProxy() override;
private:
@@ -117,16 +121,26 @@ namespace Echoion::Core
// Execute with retry/backoff (Void::Retry); single attempt via
// Void::Net::HttpClient.
[[nodiscard]] Api::Result<Api::HttpResponse>
executeWithRetry(const Api::HttpRequest& req);
[[nodiscard]] Api::Result<Api::HttpResponse>
executeRequest(const Api::HttpRequest& req);
[[nodiscard]] Api::Result<Void::Net::Response>
executeWithRetry(const Void::Net::Request& req);
[[nodiscard]] Api::Result<Void::Net::Response>
executeRequest(const Void::Net::Request& req);
std::optional<Api::ProxyConfig> proxy_;
Api::RetryConfig retryConfig_;
std::optional<Void::Net::ProxyConfig> proxy_;
mutable std::mutex mutex_;
std::atomic<bool> initialized_{false};
// Retry policy + the HTTP statuses worth retrying. Internal
// defaults — retry tuning is not part of the public client API.
Void::Retry::Policy<Void::Retry::ExponentialBackoff> retryPolicy_{
.max_attempts = 4,
.backoff = Void::Retry::ExponentialBackoff{
.base = std::chrono::milliseconds(1000),
.max = std::chrono::milliseconds(30000),
.multiplier = 2.0}};
std::vector<std::uint16_t> retryableStatusCodes_{408, 429, 500,
502, 503, 504};
// Worker pool backing the *Async / requestBatch fan-outs, replacing
// a per-call std::async OS-thread spawn with bounded thread reuse.
Void::Concurrency::ThreadPool pool_;
+2 -2
View File
@@ -106,8 +106,8 @@ namespace Echoion::Core
void setCookiesFromBrowser(const std::string& browser);
// Configure proxy for yt-dlp
void setProxyConfig(const std::optional<Api::ProxyConfig>& proxy);
[[nodiscard]] std::optional<Api::ProxyConfig>
void setProxyConfig(const std::optional<Void::Net::ProxyConfig>& proxy);
[[nodiscard]] std::optional<Void::Net::ProxyConfig>
getProxyConfig() const;
// Set YouTube API key for enhanced playlist resolution (optional)
+3 -3
View File
@@ -67,8 +67,8 @@ namespace Echoion::Core
[[nodiscard]] std::vector<std::string> getCookieArgs() const;
// Set proxy configuration for yt-dlp
void setProxyConfig(const std::optional<Api::ProxyConfig>& proxy);
[[nodiscard]] std::optional<Api::ProxyConfig>
void setProxyConfig(const std::optional<Void::Net::ProxyConfig>& proxy);
[[nodiscard]] std::optional<Void::Net::ProxyConfig>
getProxyConfig() const;
// Configure thread pool size for async operations (default: 4)
@@ -116,7 +116,7 @@ namespace Echoion::Core
std::optional<std::string> cookiesFromBrowser_;
// Proxy configuration
std::optional<Api::ProxyConfig> proxyConfig_;
std::optional<Void::Net::ProxyConfig> proxyConfig_;
mutable std::mutex proxyMutex_;
// Thread pool for async operations (Void worker pool; recreated