|
ORE Studio 0.0.4
|
Service for generating whimsical database names. More...
#include <database_name_service.hpp>

Public Member Functions | |
| database_name_service (database::context ctx) | |
| Constructs a database_name_service with database context. | |
| std::string | generate_whimsical_name () |
| Generates a whimsical name without prefix. | |
| std::string | generate_whimsical_name (bool with_suffix) |
| Generates a whimsical name with optional numeric suffix. | |
| std::string | generate_database_name (bool with_suffix=false) |
| Generates a database name with the 'ores_' prefix. | |
| std::string | generate_unique_database_name (const std::vector< std::string > &existing_names={}, int max_attempts=10) |
| Generates a unique database name not in the provided list. | |
| std::string | generate_unique_database_name_from_server () |
| Generates a unique database name by checking the server. | |
Service for generating whimsical database names.
The database_name_service generates Heroku-style memorable names for tenant databases. Names follow the pattern: ores_<adjective>_<noun>[_<number>]
Examples:
The service delegates to PostgreSQL functions defined in admin_whimsical_names_create.sql (in ores_admin database), ensuring a single source of truth for the word lists and generation logic.
NOTE: This service must connect to the ores_admin database to access the name generation functions.
Usage patterns:
|
explicit |
Constructs a database_name_service with database context.
| ctx | The database context for executing SQL functions |
| std::string generate_whimsical_name | ( | ) |
Generates a whimsical name without prefix.
| std::string generate_whimsical_name | ( | bool | with_suffix | ) |
Generates a whimsical name with optional numeric suffix.
| with_suffix | If true, appends a 4-digit number (e.g., "_4217") |
| std::string generate_database_name | ( | bool | with_suffix = false | ) |
Generates a database name with the 'ores_' prefix.
| with_suffix | If true, appends a 4-digit number |
| std::string generate_unique_database_name | ( | const std::vector< std::string > & | existing_names = {}, |
| int | max_attempts = 10 |
||
| ) |
Generates a unique database name not in the provided list.
Attempts to generate a name without suffix first. If all attempts collide with existing names, falls back to adding a numeric suffix.
| existing_names | List of already-used database names to avoid |
| max_attempts | Maximum attempts before adding suffix (default 10) |
| std::string generate_unique_database_name_from_server | ( | ) |
Generates a unique database name by checking the server.
Queries all existing databases on the PostgreSQL server that match the ores_* pattern and generates a name that doesn't conflict.