Rebased onto main at 1.4.0. The regenerated Dispatcher returns
HandlerResult<T> = expected<T, HandlerError{code, message, data}>
(ADR 0014); the covariant-return break on all 39 overrides is the swap
predicted in daemon/docs/proto-requests-m1.md P1.
- dispatcher.hpp/.cpp: Result<T> -> HandlerResult<T> on every override;
not_implemented() now returns HandlerError{InternalError, ...} rather
than a ParseError forwarded as -32603.
- download.get: returns -32010 TaskNotFound with data.taskId. Not a
placeholder — with no store, every id is genuinely not-found, which
is the real answer for contracts/ fixture download.get.not-found. It
becomes a store lookup when store/ is wired in.
- uds_roundtrip: the -32603-collapse guard is now a -32010 + data.taskId
assertion, the regression guard the P1 note promised.
download.add (-32011) and download.probe (-32013) stay InternalError
until they have real bodies (canonicalization / probe); they get their
fixture codes when that logic lands.
All 24 tests green; uds_roundtrip TSan-clean.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Upd9WhG9oppieig5nRDLig
194 lines
8.7 KiB
C++
194 lines
8.7 KiB
C++
#include "rpc/dispatcher.hpp"
|
|
|
|
namespace velox::daemon::rpc {
|
|
|
|
namespace proto = velox::proto;
|
|
|
|
namespace {
|
|
|
|
// A method whose body arrives with the store / scheduler. Answers -32603 with a clear
|
|
// message through the generated HandlerError channel (contracts/ 1.4.0, ADR 0014).
|
|
template <class T>
|
|
proto::HandlerResult<T> not_implemented(const char* method) {
|
|
return std::unexpected(proto::HandlerError{
|
|
proto::ErrorCode::InternalError,
|
|
std::string("not implemented in this build: ") + method});
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// --- session.* : handled in the server layer, unreachable here in the running daemon ---
|
|
// Kept as explicit stubs so a direct dispatch() caller (a test, a future in-process client)
|
|
// gets a clear answer rather than undefined behaviour from a missing override.
|
|
|
|
proto::HandlerResult<proto::SessionHelloResult>
|
|
VeloxDispatcher::on_session_hello(const proto::SessionHelloParams&) {
|
|
return not_implemented<proto::SessionHelloResult>("session.hello");
|
|
}
|
|
|
|
proto::HandlerResult<proto::SessionPairResult>
|
|
VeloxDispatcher::on_session_pair(const proto::SessionPairParams&) {
|
|
return not_implemented<proto::SessionPairResult>("session.pair");
|
|
}
|
|
|
|
proto::HandlerResult<proto::SessionSubscribeResult>
|
|
VeloxDispatcher::on_session_subscribe(const proto::SessionSubscribeParams&) {
|
|
return not_implemented<proto::SessionSubscribeResult>("session.subscribe");
|
|
}
|
|
|
|
// --- download.list : an empty table, so a client can connect and render ---------------
|
|
|
|
proto::HandlerResult<proto::DownloadListResult>
|
|
VeloxDispatcher::on_download_list(const proto::DownloadListParams&) {
|
|
proto::DownloadListResult r;
|
|
r.total = 0;
|
|
return r;
|
|
}
|
|
|
|
// --- everything else : not implemented until the store and scheduler land -------------
|
|
|
|
proto::HandlerResult<proto::CaptureRules>
|
|
VeloxDispatcher::on_capture_getRules(const proto::CaptureGetRulesParams&) {
|
|
return not_implemented<proto::CaptureRules>("capture.getRules");
|
|
}
|
|
proto::HandlerResult<proto::CaptureOfferResult>
|
|
VeloxDispatcher::on_capture_offer(const proto::CaptureOfferParams&) {
|
|
return not_implemented<proto::CaptureOfferResult>("capture.offer");
|
|
}
|
|
proto::HandlerResult<proto::CategoryListResult>
|
|
VeloxDispatcher::on_category_list(const proto::CategoryListParams&) {
|
|
return not_implemented<proto::CategoryListResult>("category.list");
|
|
}
|
|
proto::HandlerResult<proto::CategoryRemoveResult>
|
|
VeloxDispatcher::on_category_remove(const proto::CategoryRemoveParams&) {
|
|
return not_implemented<proto::CategoryRemoveResult>("category.remove");
|
|
}
|
|
proto::HandlerResult<proto::CategoryUpsertResult>
|
|
VeloxDispatcher::on_category_upsert(const proto::CategoryUpsertParams&) {
|
|
return not_implemented<proto::CategoryUpsertResult>("category.upsert");
|
|
}
|
|
proto::HandlerResult<proto::DownloadAddResult>
|
|
VeloxDispatcher::on_download_add(const proto::DownloadSpec&) {
|
|
return not_implemented<proto::DownloadAddResult>("download.add");
|
|
}
|
|
proto::HandlerResult<proto::DownloadAddBatchResult>
|
|
VeloxDispatcher::on_download_addBatch(const proto::DownloadAddBatchParams&) {
|
|
return not_implemented<proto::DownloadAddBatchResult>("download.addBatch");
|
|
}
|
|
proto::HandlerResult<proto::BulkTaskResult>
|
|
VeloxDispatcher::on_download_cancel(const proto::DownloadCancelParams&) {
|
|
return not_implemented<proto::BulkTaskResult>("download.cancel");
|
|
}
|
|
proto::HandlerResult<proto::TaskDetail>
|
|
VeloxDispatcher::on_download_get(const proto::DownloadGetParams& params) {
|
|
// No store is wired yet, so no task exists and every id is genuinely not-found. This
|
|
// is the real -32010 answer (contracts/ error fixture download.get.not-found), not a
|
|
// placeholder; it becomes a store lookup when store/ is wired in.
|
|
return std::unexpected(proto::HandlerError{proto::ErrorCode::TaskNotFound, "no such task",
|
|
nlohmann::json{{"taskId", params.taskId}}});
|
|
}
|
|
proto::HandlerResult<proto::BulkTaskResult>
|
|
VeloxDispatcher::on_download_pause(const proto::DownloadPauseParams&) {
|
|
return not_implemented<proto::BulkTaskResult>("download.pause");
|
|
}
|
|
proto::HandlerResult<proto::DownloadProbeResult>
|
|
VeloxDispatcher::on_download_probe(const proto::DownloadProbeParams&) {
|
|
return not_implemented<proto::DownloadProbeResult>("download.probe");
|
|
}
|
|
proto::HandlerResult<proto::DownloadProvideAuthResult>
|
|
VeloxDispatcher::on_download_provideAuth(const proto::DownloadProvideAuthParams&) {
|
|
return not_implemented<proto::DownloadProvideAuthResult>("download.provideAuth");
|
|
}
|
|
proto::HandlerResult<proto::DownloadRefreshUrlResult>
|
|
VeloxDispatcher::on_download_refreshUrl(const proto::DownloadRefreshUrlParams&) {
|
|
return not_implemented<proto::DownloadRefreshUrlResult>("download.refreshUrl");
|
|
}
|
|
proto::HandlerResult<proto::DownloadRemoveResult>
|
|
VeloxDispatcher::on_download_remove(const proto::DownloadRemoveParams&) {
|
|
return not_implemented<proto::DownloadRemoveResult>("download.remove");
|
|
}
|
|
proto::HandlerResult<proto::BulkTaskResult>
|
|
VeloxDispatcher::on_download_resume(const proto::DownloadResumeParams&) {
|
|
return not_implemented<proto::BulkTaskResult>("download.resume");
|
|
}
|
|
proto::HandlerResult<proto::BulkTaskResult>
|
|
VeloxDispatcher::on_download_start(const proto::DownloadStartParams&) {
|
|
return not_implemented<proto::BulkTaskResult>("download.start");
|
|
}
|
|
proto::HandlerResult<proto::TaskSummary>
|
|
VeloxDispatcher::on_download_update(const proto::DownloadUpdateParams&) {
|
|
return not_implemented<proto::TaskSummary>("download.update");
|
|
}
|
|
proto::HandlerResult<proto::GrabberHarvestResult>
|
|
VeloxDispatcher::on_grabber_harvest(const proto::GrabberHarvestParams&) {
|
|
return not_implemented<proto::GrabberHarvestResult>("grabber.harvest");
|
|
}
|
|
proto::HandlerResult<proto::GrabberStartResult>
|
|
VeloxDispatcher::on_grabber_start(const proto::GrabberStartParams&) {
|
|
return not_implemented<proto::GrabberStartResult>("grabber.start");
|
|
}
|
|
proto::HandlerResult<proto::GrabberStatusResult>
|
|
VeloxDispatcher::on_grabber_status(const proto::GrabberStatusParams&) {
|
|
return not_implemented<proto::GrabberStatusResult>("grabber.status");
|
|
}
|
|
proto::HandlerResult<proto::Limiter> VeloxDispatcher::on_limiter_get(const proto::LimiterGetParams&) {
|
|
return not_implemented<proto::Limiter>("limiter.get");
|
|
}
|
|
proto::HandlerResult<proto::Limiter> VeloxDispatcher::on_limiter_set(const proto::Limiter&) {
|
|
return not_implemented<proto::Limiter>("limiter.set");
|
|
}
|
|
proto::HandlerResult<proto::MediaAddVariantResult>
|
|
VeloxDispatcher::on_media_addVariant(const proto::MediaAddVariantParams&) {
|
|
return not_implemented<proto::MediaAddVariantResult>("media.addVariant");
|
|
}
|
|
proto::HandlerResult<proto::MediaListVariantsResult>
|
|
VeloxDispatcher::on_media_listVariants(const proto::MediaListVariantsParams&) {
|
|
return not_implemented<proto::MediaListVariantsResult>("media.listVariants");
|
|
}
|
|
proto::HandlerResult<proto::QueueListResult>
|
|
VeloxDispatcher::on_queue_list(const proto::QueueListParams&) {
|
|
return not_implemented<proto::QueueListResult>("queue.list");
|
|
}
|
|
proto::HandlerResult<proto::QueueReorderResult>
|
|
VeloxDispatcher::on_queue_reorder(const proto::QueueReorderParams&) {
|
|
return not_implemented<proto::QueueReorderResult>("queue.reorder");
|
|
}
|
|
proto::HandlerResult<proto::QueueStartResult>
|
|
VeloxDispatcher::on_queue_start(const proto::QueueStartParams&) {
|
|
return not_implemented<proto::QueueStartResult>("queue.start");
|
|
}
|
|
proto::HandlerResult<proto::QueueStopResult>
|
|
VeloxDispatcher::on_queue_stop(const proto::QueueStopParams&) {
|
|
return not_implemented<proto::QueueStopResult>("queue.stop");
|
|
}
|
|
proto::HandlerResult<proto::QueueUpsertResult>
|
|
VeloxDispatcher::on_queue_upsert(const proto::QueueUpsertParams&) {
|
|
return not_implemented<proto::QueueUpsertResult>("queue.upsert");
|
|
}
|
|
proto::HandlerResult<proto::RulesListResult>
|
|
VeloxDispatcher::on_rules_list(const proto::RulesListParams&) {
|
|
return not_implemented<proto::RulesListResult>("rules.list");
|
|
}
|
|
proto::HandlerResult<proto::RulesUpsertResult>
|
|
VeloxDispatcher::on_rules_upsert(const proto::RulesUpsertParams&) {
|
|
return not_implemented<proto::RulesUpsertResult>("rules.upsert");
|
|
}
|
|
proto::HandlerResult<proto::ScheduleGetResult>
|
|
VeloxDispatcher::on_schedule_get(const proto::ScheduleGetParams&) {
|
|
return not_implemented<proto::ScheduleGetResult>("schedule.get");
|
|
}
|
|
proto::HandlerResult<proto::ScheduleSetResult>
|
|
VeloxDispatcher::on_schedule_set(const proto::ScheduleSetParams&) {
|
|
return not_implemented<proto::ScheduleSetResult>("schedule.set");
|
|
}
|
|
proto::HandlerResult<proto::SettingsGetResult>
|
|
VeloxDispatcher::on_settings_get(const proto::SettingsGetParams&) {
|
|
return not_implemented<proto::SettingsGetResult>("settings.get");
|
|
}
|
|
proto::HandlerResult<proto::SettingsSetResult>
|
|
VeloxDispatcher::on_settings_set(const proto::SettingsSetParams&) {
|
|
return not_implemented<proto::SettingsSetResult>("settings.set");
|
|
}
|
|
|
|
} // namespace velox::daemon::rpc
|