Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DBModule = fx.Module("database", fx.Provide(GetPostgresConfig), fx.Provide(postgres.NewConnect), fx.Provide(postgres.NewDBHolder), fx.Invoke(func(config *postgres.PgConfig) { postgres.DbConfig = config }), fx.Invoke(func(db *gorm.DB) { postgres.CheckConnection(db) }), )
DBModule is an Fx module that provides the configuration, connection, and holder for PostgreSQL database integration. It initializes the PostgreSQL configuration, establishes a connection, and verifies connectivity.
View Source
var DatabaseFlags = []cli.Flag{ &cli.StringFlag{ Name: postgresUser, Value: "test", Usage: "PostgreSQL database username", EnvVars: []string{"POSTGRES_USER", "PG_USER"}, }, &cli.StringFlag{ Name: postgresPassword, Value: "test", Usage: "PostgreSQL database user password", EnvVars: []string{"POSTGRES_PASSWORD", "PG_PASSWORD"}, }, &cli.StringFlag{ Name: postgresDb, Value: "node_art_slot_games", Usage: "PostgreSQL database name", EnvVars: []string{"POSTGRES_DB", "PG_DB"}, }, &cli.StringFlag{ Name: postgresSchema, Value: "public", Usage: "PostgreSQL database schema", EnvVars: []string{"POSTGRES_SCHEMA", "PG_SCHEMA"}, }, &cli.StringFlag{ Name: postgresHost, Value: "localhost:5432", Usage: "PostgreSQL database host address", EnvVars: []string{"POSTGRES_HOST", "PG_HOST"}, }, &cli.StringFlag{ Name: postgresConnectionMaxLifeTime, Value: "20", Usage: "Maximum lifetime of a PostgreSQL connection in milliseconds", EnvVars: []string{"POSTGRES_CONNECTION_MAX_LIFE_TIME"}, }, &cli.StringFlag{ Name: postgresMaxOpenConnection, Value: "300", Usage: "Maximum number of open PostgreSQL connections", EnvVars: []string{"POSTGRES_MAX_OPEN_CONNECTION"}, }, &cli.BoolFlag{ Name: postgresLogMode, Value: true, Usage: "Enable or disable query logging in PostgreSQL", EnvVars: []string{"POSTGRES_QUERY_LOGGING"}, }, }
DatabaseFlags defines CLI flags for configuring PostgreSQL connections. These flags allow database connection settings to be specified via command-line arguments or environment variables.
Functions ¶
func GetPostgresConfig ¶
GetPostgresConfig creates and returns a PgConfig structure containing PostgreSQL configuration settings for establishing database connections.
Parameters:
- c: The CLI context from which configuration values are read.
Returns:
A pointer to a PgConfig struct with PostgreSQL settings.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.