fix: env
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.ma-al.com/goc_marek/replica/pkg/replica"
|
"git.ma-al.com/goc_marek/replica/replica"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
MARIADB_USER: ${MARIA_USER}
|
MARIADB_USER: ${MARIA_USER}
|
||||||
MARIADB_PASSWORD: ${MARIA_PASS}
|
MARIADB_PASSWORD: ${MARIA_PASS}
|
||||||
MYSQL_DATABASE: ${MARIA_NAME}
|
MARIADB_DATABASE: ${MARIA_NAME}
|
||||||
MYSQL_ROOT_PASSWORD: ${MARIA_PASS}
|
MARIADB_ROOT_PASSWORD: ${MARIA_PASS}
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
mariadb-secondary:
|
mariadb-secondary:
|
||||||
@@ -46,27 +46,12 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
MARIADB_USER: ${MARIA_USER}
|
MARIADB_USER: ${MARIA_USER}
|
||||||
MARIADB_PASSWORD: ${MARIA_PASS}
|
MARIADB_PASSWORD: ${MARIA_PASS}
|
||||||
MYSQL_DATABASE: ${MARIA_NAME}
|
MARIADB_DATABASE: ${MARIA_NAME}
|
||||||
MYSQL_ROOT_PASSWORD: ${MARIA_PASS}
|
MARIADB_ROOT_PASSWORD: ${MARIA_PASS}
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- mariadb-primary
|
- mariadb-primary
|
||||||
|
|
||||||
# postgresql:
|
|
||||||
# container_name: ${POSTGRES_HOST}
|
|
||||||
# restart: always
|
|
||||||
# image: postgres:18
|
|
||||||
# networks:
|
|
||||||
# repl:
|
|
||||||
# ports:
|
|
||||||
# - 5432:5432
|
|
||||||
# volumes:
|
|
||||||
# - postgres-data:/var/lib/postgresql:Z
|
|
||||||
# command: postgres -c shared_buffers=512MB -c work_mem=16MB -c maintenance_work_mem=256MB -c effective_cache_size=4GB -c max_connections=20
|
|
||||||
# environment:
|
|
||||||
# POSTGRES_USER: ${POSTGRES_USER}
|
|
||||||
# POSTGRES_PASSWORD: ${POSTGRES_PASS}
|
|
||||||
# POSTGRES_DB: ${POSTGRES_NAME}
|
|
||||||
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Primary MariaDB Configuration
|
# Primary MariaDB Configuration
|
||||||
MARIA_USER=replica
|
MARIA_USER=replica
|
||||||
MARIA_PASS=replica
|
MARIA_PASS=replica
|
||||||
|
MARIA_NAME=replica
|
||||||
MARIA_SERVER_ID=100
|
MARIA_SERVER_ID=100
|
||||||
MARIA_PRIMARY_HOST=mariadb-primary
|
MARIA_PRIMARY_HOST=mariadb-primary
|
||||||
MARIA_PRIMARY_PORT=3306
|
MARIA_PRIMARY_PORT=3306
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -11,6 +11,7 @@ require (
|
|||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
github.com/google/uuid v1.3.0 // indirect
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
|
github.com/joho/godotenv v1.5.1 // indirect
|
||||||
github.com/klauspost/compress v1.17.8 // indirect
|
github.com/klauspost/compress v1.17.8 // indirect
|
||||||
github.com/pingcap/errors v0.11.5-0.20250318082626-8f80e5cb09ec // indirect
|
github.com/pingcap/errors v0.11.5-0.20250318082626-8f80e5cb09ec // indirect
|
||||||
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a // indirect
|
github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a // indirect
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -12,6 +12,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
|||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
|
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
|
||||||
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BinlogConfig holds the configuration for connecting to MySQL/MariaDB binlog
|
// BinlogConfig holds the configuration for connecting to MySQL/MariaDB binlog
|
||||||
@@ -55,6 +57,12 @@ type AppConfig struct {
|
|||||||
|
|
||||||
// LoadEnvConfig loads configuration from environment variables
|
// LoadEnvConfig loads configuration from environment variables
|
||||||
func LoadEnvConfig() (*AppConfig, error) {
|
func LoadEnvConfig() (*AppConfig, error) {
|
||||||
|
// Load .env file
|
||||||
|
if err := godotenv.Load(); err != nil {
|
||||||
|
// It's not an error if the .env file doesn't exist
|
||||||
|
// We just use the system environment variables
|
||||||
|
}
|
||||||
|
|
||||||
cfg := &AppConfig{
|
cfg := &AppConfig{
|
||||||
BatchSize: 1000,
|
BatchSize: 1000,
|
||||||
ExcludeSchemas: []string{"information_schema", "performance_schema", "mysql", "sys"},
|
ExcludeSchemas: []string{"information_schema", "performance_schema", "mysql", "sys"},
|
||||||
Reference in New Issue
Block a user