20#ifndef KICAD_DB_BACKEND_SUPPORT_H
21#define KICAD_DB_BACKEND_SUPPORT_H
40inline std::string
utf8(
const wxString& aText )
42 return std::string( aText.ToUTF8() );
114std::string
ScrubSecret( std::string aText,
const std::string& aSecret );
118std::string
RedactDetail(
const std::string& aDetail,
const std::string& aSecret );
137 std::optional<T>
Get( std::chrono::milliseconds aWait )
142 auto promise = std::make_shared<std::promise<T>>();
144 m_answer = promise->get_future().share();
151 promise->set_value( probe() );
155 promise->set_value(
T() );
161 const std::shared_future<T> answer =
m_answer;
163 if( answer.wait_for( aWait ) != std::future_status::ready )
std::optional< T > Get(std::chrono::milliseconds aWait)
The probe's answer, or nothing if it has not finished within aWait. A probe that throws answers T().
std::shared_future< T > m_answer
DB_PROBE_LATCH(std::function< T()> aProbe)
std::function< T()> m_probe
const DB_ROW_SINK & m_sink
DB_READ_DELIVERY & operator=(const DB_READ_DELIVERY &)=delete
bool SinkThrew() const
True if the caller's sink threw.
DB_READ_DELIVERY(const DB_READ_DELIVERY &)=delete
DB_READ_DELIVERY(std::vector< std::string > &aLabels, const DB_ROW_SINK &aSink)
std::shared_ptr< std::vector< std::string > > m_jobLabels
const std::shared_ptr< std::vector< std::string > > & Labels() const
The labels the job fills in.
std::vector< std::string > & m_labels
void Finish()
Copies the labels out if no row did, after the call returned a result.
const DB_ROW_SINK * Sink() const
The sink to pass to the worker call.
static std::string SinkFailureMessage()
The message for a read the caller's sink gave up on.
OUTCOME
Why the last Run or RunCleanup returned without a result.
std::function< void(std::vector< DB_VALUE > &&)> DB_ROW_SINK
Receives one row at a time, in the order of the labels the read produced.
DB_FAILURE
Why a connection attempt failed, as far as the backend's report tells.
DB_WORKER_FAILURE DescribeWorkerOutcome(DB_WORKER_THREAD::OUTCOME aOutcome, const std::string &aPath)
Maps the outcome of a call that returned no result to a failure and a connection decision.
std::string ScrubSecret(std::string aText, const std::string &aSecret)
Replaces a secret in a message, as ***.
std::string utf8(const wxString &aText)
std::string RedactDetail(const std::string &aDetail, const std::string &aSecret)
The provider text to show for a call made with aSecret, which is nothing at all when the secret is sh...
What a backend reports, and what it does with its connection, when a worker call did not complete.
@ KEEP
Nothing ran, so the connection is intact.
@ DROP
The connection is closed through the worker.
@ FORGET
The stuck job releases the connection itself when its blocked call returns.