Lightweight 0.20260921.0
Loading...
Searching...
No Matches
Lightweight::SqlRetryClassifier Class Referenceabstract

Dialect-specific classification of SQL errors into transient and permanent. More...

#include <SqlRetryClassifier.hpp>

Public Member Functions

virtual ~SqlRetryClassifier ()=default
 Polymorphic destructor.
 
 SqlRetryClassifier (SqlRetryClassifier const &)=delete
 
SqlRetryClassifier & operator= (SqlRetryClassifier const &)=delete
 
 SqlRetryClassifier (SqlRetryClassifier &&)=delete
 
SqlRetryClassifier & operator= (SqlRetryClassifier &&)=delete
 
virtual SqlErrorTransience Classify (SqlErrorInfo const &error) const noexcept=0
 
bool IsTransient (SqlErrorInfo const &error) const noexcept
 

Detailed Description

Dialect-specific classification of SQL errors into transient and permanent.

Every SqlQueryFormatter returns a process-singleton instance of the appropriate concrete classifier via SqlQueryFormatter::RetryOps(), which is what keeps per-DBMS error-code knowledge out of business logic: callers ask the formatter, never SqlServerType directly.

The dialects genuinely disagree. PostgreSQL reports a serialization failure as SQLSTATE 40001 and a lock it could not take as 55P03; SQL Server reports the deadlock victim as native error 1205 under a generic SQLSTATE; SQLite reports a busy database as a message string with no usable SQLSTATE at all. A single hard-coded predicate cannot be right for all three, which is why this is a dispatch point rather than a free function.

Callers normally reach a classifier through SqlRetryPolicy rather than using it directly; this type is the extension point for adding a new dialect.

Definition at line 52 of file SqlRetryClassifier.hpp.

Member Function Documentation

◆ Classify()

virtual SqlErrorTransience Lightweight::SqlRetryClassifier::Classify ( SqlErrorInfo const &  error) const
pure virtualnoexcept

Classifies the given error.

Implementations must be pure: no I/O, no handle access, no hidden state. That is what lets a test drive every branch by constructing a SqlErrorInfo, rather than having to provoke a real driver failure.

Parameters
errorThe error reported by the failed attempt.
Returns
Whether another attempt could plausibly succeed.

◆ IsTransient()

bool Lightweight::SqlRetryClassifier::IsTransient ( SqlErrorInfo const &  error) const
inlinenoexcept

Convenience predicate over Classify.

Parameters
errorThe error reported by the failed attempt.
Returns
true if error is classified as SqlErrorTransience::Transient.

Definition at line 78 of file SqlRetryClassifier.hpp.


The documentation for this class was generated from the following file: