VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
DatabaseConfig.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5namespace VoltMod
6{
7
8/**
9 * @brief Connection parameters for every supported backend.
10 *
11 * Field names are lowercase so a consumer's JSON config section maps onto them directly:
12 * reflection reads the members, so a plugin needs no mapper - embedding this in a settings
13 * struct is all there is to do.
14 *
15 * The dependency-free header keeps settings structs usable in SDK-free tests and translation
16 * units that do not link a database client.
17 */
19{
20 /** "postgres", "mariadb" or "sqlite"; anything else fails `Database::Connect`. */
21 std::string driver = "postgres";
22 std::string host = "localhost";
23 /** 0 uses the driver default (5432 for Postgres, 3306 for MariaDB). Ignored by sqlite. */
24 int port = 0;
25 std::string database = "voltmod_server";
26 std::string username = "voltmod_plugin";
27 std::string password;
28 /** Postgres sslmode: disable, allow, prefer, require, verify-ca or verify-full. MariaDB
29 * turns TLS on for require and the verify modes; sqlite ignores it. */
30 std::string sslMode = "prefer";
31 /** Bounds every (re)connect attempt so a dead database can't hang queries or unload. */
33 /** sqlite database file, relative to the game dir. ":memory:" is allowed. */
34 std::string path;
35};
36
37} // namespace VoltMod
Connection parameters for every supported backend.