The current MySQL implementation uses the basic C API
The newer C++ API (MySQL X DevAPI) appears to support automatic failover, reconnecting to alternative MySQL servers.
The Java connector documentation gives a URL example:
The API docs for C++ mention similar capabilities:
In particular, look for MYSQLX_OPT_PRIORITY
It looks like libpq supports this since 2016:
so PostgreSQL users may be able to do this already. Changing from MySQL to PostgreSQL might be a suitable workaround for some users.