|
cwist
Modern C web framework with libttak runtime
|
Automatic RDBMS provider detection and runtime mounting. More...
#include <stdlib.h>#include <string.h>#include <unistd.h>#include <errno.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/time.h>#include <cwist/sys/app/app.h>#include <cwist/core/log.h>#include <cwist/core/mem/alloc.h>
Go to the source code of this file.
Functions | |
| cwist_rdbms_provider_t | cwist_rdbms_probe_port (int port) |
| Probe a TCP port on 127.0.0.1 to detect the RDBMS provider. | |
| bool | cwist_rdbms_mount_runtime (cwist_app *app, cwist_rdbms_provider_t provider, int port) |
| Allocate and attach an RDBMS runtime record to an app. | |
| bool | cwist_app_auto_rdbms (cwist_app *app, int port) |
| Auto-detect an RDBMS on a local port and mount its runtime on an app. | |
Automatic RDBMS provider detection and runtime mounting.
Definition in file rdbms_auto_mount.c.
Auto-detect an RDBMS on a local port and mount its runtime on an app.
Auto-detect and mount an RDBMS runtime by probing a TCP port.
Probes port via cwist_rdbms_probe_port(); on success the detected provider's runtime is mounted with cwist_rdbms_mount_runtime().
| app | App to attach the runtime to; must not be NULL. |
| port | TCP port on localhost to probe. |
Definition at line 189 of file rdbms_auto_mount.c.
References CWIST_LOG_ERROR, cwist_rdbms_mount_runtime(), CWIST_RDBMS_NONE, cwist_rdbms_probe_port(), cwist_rdbms_runtime::port, and cwist_rdbms_runtime::provider.
| bool cwist_rdbms_mount_runtime | ( | cwist_app * | app, |
| cwist_rdbms_provider_t | provider, | ||
| int | port | ||
| ) |
Allocate and attach an RDBMS runtime record to an app.
Mount an RDBMS runtime for the given provider and port.
Idempotent: if app already has an RDBMS runtime mounted, this returns true without allocating. On success the new runtime is stored in app->rdbms with ready set to true.
| app | App to attach the runtime to; must not be NULL. |
| provider | Detected provider stored in the runtime. |
| port | Port the provider was detected on. |
Definition at line 155 of file rdbms_auto_mount.c.
References cap, cwist_alloc_array(), CWIST_LOG_ERROR, CWIST_LOG_INFO, cwist_rdbms_runtime::port, cwist_rdbms_runtime::provider, and cwist_app::rdbms.
Referenced by cwist_app_auto_rdbms().
| cwist_rdbms_provider_t cwist_rdbms_probe_port | ( | int | port | ) |
Probe a TCP port on 127.0.0.1 to detect the RDBMS provider.
Probe a TCP port for an RDBMS wire protocol.
Connects to the given port with a 2-second send/recv timeout, inspects any unsolicited handshake bytes as a MySQL/MariaDB handshake, and if that does not match, sends a PostgreSQL StartupMessage and waits for an AuthenticationRequest response.
| port | TCP port on localhost to probe. |
CWIST_RDBMS_MYSQL, CWIST_RDBMS_MARIADB, or CWIST_RDBMS_POSTGRES) or CWIST_RDBMS_NONE if detection fails. The socket is always closed before returning. Definition at line 83 of file rdbms_auto_mount.c.
References cap, CWIST_LOG_ERROR, CWIST_RDBMS_NONE, and CWIST_RDBMS_POSTGRES.
Referenced by cwist_app_auto_rdbms().