Refactor go.mod to remove indirect dependency on godotenv and update RQLite node configuration

This commit is contained in:
anonpenguin 2025-08-04 18:51:11 +03:00
parent bf32cc2a49
commit cad45efb71
7 changed files with 16 additions and 9 deletions

View File

@ -36,9 +36,13 @@ func main() {
fmt.Sprintf("/ip4/0.0.0.0/udp/%d/quic", *port), fmt.Sprintf("/ip4/0.0.0.0/udp/%d/quic", *port),
} }
// Configure RQLite ports based on node port // Configure RQLite ports based on node port (only if not already set in config)
cfg.Database.RQLitePort = *port + 1000 // e.g., 5002 for node port 4002 if cfg.Database.RQLitePort == 0 {
cfg.Database.RQLiteRaftPort = *port + 3000 // e.g., 7002 for node port 4002 (changed to avoid conflicts) cfg.Database.RQLitePort = *port + 1000 // e.g., 5002 for node port 4002
}
if cfg.Database.RQLiteRaftPort == 0 {
cfg.Database.RQLiteRaftPort = *port + 3000 // e.g., 7002 for node port 4002 (changed to avoid conflicts)
}
// Configure bootstrap peers // Configure bootstrap peers
if *bootstrap != "" { if *bootstrap != "" {

View File

@ -14,6 +14,8 @@ database:
shard_count: 16 shard_count: 16
max_database_size: 1073741824 # 1GB max_database_size: 1073741824 # 1GB
backup_interval: "24h" backup_interval: "24h"
rqlite_port: 5001
rqlite_raft_port: 5002
discovery: discovery:
bootstrap_peers: [] # Bootstrap nodes don't need peers bootstrap_peers: [] # Bootstrap nodes don't need peers

View File

@ -14,6 +14,8 @@ database:
shard_count: 16 shard_count: 16
max_database_size: 1073741824 # 1GB max_database_size: 1073741824 # 1GB
backup_interval: "24h" backup_interval: "24h"
rqlite_port: 5001
rqlite_raft_port: 5002
discovery: discovery:
bootstrap_peers: bootstrap_peers:

2
go.mod
View File

@ -5,6 +5,7 @@ go 1.23.8
toolchain go1.24.1 toolchain go1.24.1
require ( require (
github.com/joho/godotenv v1.5.1
github.com/libp2p/go-libp2p v0.41.1 github.com/libp2p/go-libp2p v0.41.1
github.com/libp2p/go-libp2p-kad-dht v0.33.1 github.com/libp2p/go-libp2p-kad-dht v0.33.1
github.com/libp2p/go-libp2p-pubsub v0.14.2 github.com/libp2p/go-libp2p-pubsub v0.14.2
@ -44,7 +45,6 @@ require (
github.com/ipld/go-ipld-prime v0.21.0 // indirect github.com/ipld/go-ipld-prime v0.21.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/koron/go-ssdp v0.0.5 // indirect github.com/koron/go-ssdp v0.0.5 // indirect

View File

@ -215,10 +215,9 @@ func (d *DatabaseClientImpl) getRQLiteNodes() []string {
// Fallback to localhost for development // Fallback to localhost for development
return []string{ return []string{
"http://localhost:5001", // bootstrap "http://localhost:5001", // bootstrap
"http://localhost:5002", // node1 "http://localhost:5002", // node1
"http://localhost:5003", // node2 "http://localhost:5003", // node2
"http://localhost:5004", // node3 (if exists) "http://localhost:5004", // node3 (if exists)
"http://localhost:5005", // node4 (if exists)
} }
} }

View File

@ -121,8 +121,8 @@ func DefaultConfig() *Config {
BackupInterval: time.Hour * 24, // Daily backups BackupInterval: time.Hour * 24, // Daily backups
// RQLite-specific configuration // RQLite-specific configuration
RQLitePort: 4001, RQLitePort: 5001,
RQLiteRaftPort: 4002, RQLiteRaftPort: 5002,
RQLiteJoinAddress: "", // Empty for bootstrap node RQLiteJoinAddress: "", // Empty for bootstrap node
}, },
Discovery: DiscoveryConfig{ Discovery: DiscoveryConfig{

View File

@ -17,7 +17,7 @@ REPO_URL="https://git.debros.io/DeBros/network.git"
MIN_GO_VERSION="1.19" MIN_GO_VERSION="1.19"
NODE_PORT="4001" NODE_PORT="4001"
RQLITE_NODE_PORT="5001" RQLITE_NODE_PORT="5001"
RAFT_NODE_PORT="7001" RAFT_NODE_PORT="5002"
UPDATE_MODE=false UPDATE_MODE=false
NON_INTERACTIVE=false NON_INTERACTIVE=false