feat(cli): reach instances over QUIC
crafter-debug had a placeholder transport that reported every instance unreachable. Cli::ConnectQuic dials 127.0.0.1 at the port in the discovery record on the first call, keeps the connection for the next, and dials again after one is lost. Each call opens a stream, sends the request with a FIN, and reads lines: one with a result or an error is the reply, anything before it a stream line for onLine, which runs on the calling thread so a slow terminal never stalls msquic's worker. Past the deadline the stream is aborted and the call times out. The handshake gives up after 3 s, and keep-alives every 2 s hold a quiet follow or a long wait open under the 10 s idle timeout. main starts a pool with one worker, which Network reports some failures on, and ends with _Exit once Run has closed its connections, since msquic's teardown at exit waits on connections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
47f2325664
commit
f8024b7a43
5 changed files with 204 additions and 19 deletions
|
|
@ -1,26 +1,30 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
// crafter-debug: Cli::Run with the real transport.
|
||||
// crafter-debug: Cli::Run with the QUIC transport.
|
||||
import std;
|
||||
import Crafter.Thread;
|
||||
import Crafter.Debug.Core;
|
||||
import Crafter.Debug.Cli;
|
||||
using namespace Crafter::Debug;
|
||||
|
||||
namespace {
|
||||
// Until the QUIC transport lands: every call reports it unreachable.
|
||||
class Unbuilt : public Cli::Connection {
|
||||
public:
|
||||
std::expected<Value, Cli::CallError> Call(const Value&, std::chrono::milliseconds, const std::function<bool(const Value&)>&) override {
|
||||
return std::unexpected(Cli::CallError{ Cli::CallError::Kind::Unreachable, "this client was built without its transport" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Crafter.Network reports some failures through the pool. One request
|
||||
// at a time needs one worker.
|
||||
Crafter::ThreadPool::Start(2);
|
||||
const std::vector<std::string_view> args(argv + 1, argv + argc);
|
||||
Cli::Environment environment;
|
||||
environment.connect = [](const InstanceRecord&) -> std::unique_ptr<Cli::Connection> { return std::make_unique<Unbuilt>(); };
|
||||
environment.haveLldb = [] { return std::filesystem::exists("/app/bin/lldb") || std::filesystem::exists("/usr/bin/lldb"); };
|
||||
return Cli::Run(args, environment);
|
||||
std::int32_t code = 0;
|
||||
{
|
||||
Cli::Environment environment;
|
||||
environment.connect = Cli::ConnectQuic;
|
||||
environment.haveLldb = [] { return std::filesystem::exists("/app/bin/lldb") || std::filesystem::exists("/usr/bin/lldb"); };
|
||||
// Run closes its connections before it returns.
|
||||
code = Cli::Run(args, environment);
|
||||
}
|
||||
std::cout.flush();
|
||||
std::cerr.flush();
|
||||
std::fflush(nullptr);
|
||||
// Not through exit: msquic's teardown at exit waits for connections,
|
||||
// and the pool's workers would need stopping first.
|
||||
std::_Exit(code);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue