CommandManager dispatched async commands through a bespoke pool — a jthread
vector, a CommandTask queue, a mutex/condition_variable, and a manual
drain-on-shutdown loop. Replace it with a Void::Concurrency::ThreadPool:
- startThreadPool() builds the pool at THREAD_POOL_SIZE; shutdown() flips
the accept flag and resets the pool (~ThreadPool drains queued commands
then joins — the same shutdown semantics the manual loop had).
- dispatch() submits the CommandTask lambda straight to the pool instead of
enqueuing + notifying; executeCommandAsync already swallows exceptions, so
the discarded future is safe.
- processCommandQueue() and the queue/cv/worker members are gone.
Build green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
YtDlpManager carried a bespoke worker pool — a jthread vector, a
packaged_task queue, and a mutex/condition_variable/stop-flag loop. Swap
all of it for a single Void::Concurrency::ThreadPool (held by unique_ptr so
setThreadPoolSize can recreate it):
- startThreadPool() constructs the pool at the (auto-adjusted) size;
stopThreadPool() resets it (the destructor drains and joins).
- executeAsync() submits to the pool under mutex_ (mutually exclusive with
start/stop), with a synchronous fallback if called before start.
- workerThread() and the taskQueue_/taskCv_/taskMutex_/stopThreads_ members
are gone.
Behaviorally equivalent (bounded yt-dlp concurrency, same std::future
results) with far less concurrency code to own. Build green.
The init-time "update yt-dlp in background" detached thread is left as-is:
it's a one-shot fired before the pool exists.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the per-call std::async OS-thread spawns in the blocking
fan-out/collect paths with a bounded Void::Concurrency::ThreadPool member,
giving thread reuse instead of an unbounded thread per request:
- YouTubeClient: getVideoInfoAsync, getPlaylistAsync, and the two playlist
resolution batches now submit to pool_. The std::future<T>/.get() join
semantics are unchanged, so control flow is identical.
- NetworkClient: getAsync/postAsync/requestAsync (and thus requestBatch)
submit to pool_.
populateShortenedUrls is deliberately left on std::async — it relies on
wide parallelism under a tight 5s budget, which a bounded pool would
throttle. Build green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the parallel *Json mirror structs and the ~370 LOC of field-by-field
mapping in ConfigLoader and Core. Api::AppConfig is now reflected straight
to/from JSON:
- ConfigLoader::{loadFromFile,saveToFile} use from_json/to_json<AppConfig>
directly; a small normalize() keeps the yt-dlp concurrency cap that the
mapping layer used to enforce.
- Core::{getConfigJson,updateConfigJson} likewise reflect directly, which
also extends them to honor youtube/features/advanced sections that the
old hand-mapping silently dropped.
- parseQuality/qualityToString removed — enums serialize by name.
On-disk format change (v3, clean cutover): durations are strings
("30000ms", also accepts "30s"/"5m"/"1h"), enums are names, the proxy is a
nested object (or null) instead of flat proxyType/proxyHost fields, and the
admin/custom sections now round-trip. Verified: build green, a
serialize->parse->deserialize round-trip of AppConfig (incl. a SOCKS5
proxy) passes, and config.example.json loads through the reflection path.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The DI registry was write-only — populated in Core::initialize() but never
resolved through. Thread it into command execution so commands resolve
shared services by interface instead of constructing throwaways:
- CommandContext gains a non-owning ServiceRegistry* plus an ergonomic
service<I>() resolver.
- CommandManager carries the registry (Core::setServices(®istry_)) and
stamps it onto every CommandContext it builds (async + sync paths).
- RpcInfoCommand's getPublicIpAddress() now reuses the shared, initialized
INetworkClient from the registry, falling back to a throwaway client only
when none is registered.
Core itself (the composition root) keeps direct member wiring and commands
keep explicit MusicManager injection — converting those to a service locator
would only hide dependencies; the registry earns its keep at the genuine
seam where a command needs a service it isn't handed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace YouTubeClient's local jHas/jStr/jNum/jObj/jArr free-function helpers
(and their ~77 call sites) with the new Void::Json::Value member accessors
has/get_str/get_num/child_object/child_array. Same safe semantics
(missing/wrong-type → default/nullptr), now shared across the project.
Requires the VoidLibrary re-pin that adds the accessors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mechanically convert std::unexpected(Api::Error(ErrorCode::X, msg[, src]))
to Api::fail(ErrorCode::X, msg[, src]) across Core. Pure syntax; forwards of
existing errors (std::unexpected(x.error())) are unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Remove YouTubeClient::urlEncode/decodeHtmlEntities/parseIso8601Duration and
StateSerializer::getCurrentTimestampISO8601 — each just forwarded to one Void
call — and have the ~12 call sites call Void directly
(Void::Encoding::Url::encode, Void::Text::html_unescape,
Void::Time::parse_iso8601_interval(...).value_or(0), Void::Time::utc_now_iso8601).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Void::Plugin::PluginLoader::reload() transfers state (deserialize_state)
before on_load(), on a freshly-created instance — but Core's
restoreAfterHotReload needs an initialized Core. Make the adapter
self-initialize from the default config path in both on_load() (first load /
post-swap) and deserialize_state (during transfer), guarded by
isInitialized() so it is idempotent. This resolves the init-before-restore
ordering and lets the host migrate to PluginManager as plain wiring.
The legacy CreateCore path is unaffected (on_load is only reached through the
void_plugin_* C ABI). Live hot-reload state-survival under TeamSpeak remains
the runtime gate.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a CorePlugin adapter (IS-A Void::Plugin::IPlugin and IS-A Core, hence
Api::ICoreInterface) and export the void_plugin_* C ABI from Export.cpp:
create/destroy/info plus the v2 state protocol (serialize/deserialize routed
through Core's already-Void::Json prepareForHotReload/restoreAfterHotReload).
The host recovers the bot interface by dynamic_cast-ing the IPlugin* back to
ICoreInterface*.
Additive: the legacy CreateCore/DestroyCore exports stay, so the current
dylib CoreLoader keeps working while the host migrates to
Void::Plugin::PluginManager. Verified via a dlopen smoke test (symbols
resolve; info/version correct; create/serialize/deserialize/destroy safe on
an uninitialized Core). The live hot-reload + state-survival test under
TeamSpeak is the remaining gate for the host-side loader swap. Link
Void::Plugin.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add Void::Service::ServiceRegistry to Core. initialize() now registers every
service by interface — ILogger, ConfigManager, EventBus, INetworkClient,
Database, MusicManager, RpcServer — so code can resolve them via
Core::services().require<I>() instead of reaching for global singletons. The
three former singletons (logger/config/event bus) are wrapped in non-owning
aliasing shared_ptrs and remain valid behind the ECHOION_LOG_*/PUBLISH/
SUBSCRIBE macros; the registry just makes them discoverable as services.
This establishes the DI backbone; migrating individual call sites to
registry resolution is intentionally incremental. Requires the VoidLibrary
fix allowing non-polymorphic service types in provide<I>. Link Void::Service.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
DatabaseImpl now holds a Void::Sqlite::Database (RAII open/close, WAL +
busy-timeout + foreign_keys); the existing raw-sqlite3 query methods borrow
its handle() unchanged. Removes the manual sqlite3_open/close + journal-mode
boilerplate.
Deliberately keeps echoion's schema_migrations migration framework rather
than switching to Void's PRAGMA user_version Migrator: existing databases
record versions in schema_migrations with user_version=0, and migrations
2/3 DROP tables — re-running them would destroy live data. Verified with an
integration test (data survives close+reopen; migrate() stays idempotent).
Link Void::Sqlite.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the ~700-line hand-rolled HTTP stack (Boost.Beast/Asio client,
URL parsing, HTTP-CONNECT + SOCKS5 proxy handshakes, a bespoke 4-thread
packaged_task pool) with a thin adapter over Void::Net::HttpClient that
still implements Api::INetworkClient. Translates Api::HttpRequest/Response/
ProxyConfig <-> Void::Net types; retry/backoff stays on Void::Retry; async
methods use std::async. Link Void::Net.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>