Files
moloapp/src/clients/transport.h
T
retoor 3c4334cec9 feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security,
data, app, realtime, supervisor, clients, CLI, example plus
enterprise tenancy, audit, operability, governance,
supplychain. Postgres via docker compose for tests.
2026-10-23 18:20:04 +02:00

41 lines
1.2 KiB
C++

#pragma once
// Transport interface. Real network, in-process dispatch, and scripted mocks
// all implement this; callers never change when the transport swaps.
#include <stdexcept>
#include <string>
#include "clients/body/stream.h"
#include "clients/request.h"
#include "clients/response.h"
#include "clients/task.h"
namespace molo::clients {
class TransportError : public std::runtime_error {
public:
explicit TransportError(const std::string& msg, bool connect_phase = false)
: std::runtime_error("molo::clients::Transport: " + msg),
connect_phase_(connect_phase) {}
// True when the failure happened before any request byte was sent, so
// even non-idempotent methods may retry.
bool connect_phase() const noexcept { return connect_phase_; }
private:
bool connect_phase_;
};
class Transport {
public:
virtual ~Transport() = default;
virtual const char* name() const = 0;
virtual Task<ClientResponse> send(const ClientRequest& request) = 0;
// Streamed download. Default implementation buffers through send().
virtual Task<void> send_stream(const ClientRequest& request,
body::ChunkSink sink);
virtual void close() {}
};
} // namespace molo::clients