mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 22:58:49 +00:00
chore: update version and enhance database connection configuration
- Bumped version from 0.52.15 to 0.52.16 in the Makefile. - Added connection pool configuration with timeouts and limits in the RQLite adapter and gateway, improving database connection management.
This commit is contained in:
parent
061b17de4f
commit
56dc6892de
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ test-e2e:
|
||||
|
||||
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports
|
||||
|
||||
VERSION := 0.52.15
|
||||
VERSION := 0.52.16
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||
|
||||
@ -108,13 +108,22 @@ func New(logger *logging.ColoredLogger, cfg *Config) (*Gateway, error) {
|
||||
if dbErr != nil {
|
||||
logger.ComponentWarn(logging.ComponentGeneral, "failed to open rqlite sql db; http orm gateway disabled", zap.Error(dbErr))
|
||||
} else {
|
||||
// Configure connection pool with proper timeouts and limits
|
||||
db.SetMaxOpenConns(25) // Maximum number of open connections
|
||||
db.SetMaxIdleConns(5) // Maximum number of idle connections
|
||||
db.SetConnMaxLifetime(5 * time.Minute) // Maximum lifetime of a connection
|
||||
db.SetConnMaxIdleTime(2 * time.Minute) // Maximum idle time before closing
|
||||
|
||||
gw.sqlDB = db
|
||||
orm := rqlite.NewClient(db)
|
||||
gw.ormClient = orm
|
||||
gw.ormHTTP = rqlite.NewHTTPGateway(orm, "/v1/db")
|
||||
// Set a reasonable timeout for HTTP requests (30 seconds)
|
||||
gw.ormHTTP.Timeout = 30 * time.Second
|
||||
logger.ComponentInfo(logging.ComponentGeneral, "RQLite ORM HTTP gateway ready",
|
||||
zap.String("dsn", dsn),
|
||||
zap.String("base_path", "/v1/db"),
|
||||
zap.Duration("timeout", gw.ormHTTP.Timeout),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package rqlite
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
_ "github.com/rqlite/gorqlite/stdlib" // Import the database/sql driver
|
||||
)
|
||||
@ -21,6 +22,12 @@ func NewRQLiteAdapter(manager *RQLiteManager) (*RQLiteAdapter, error) {
|
||||
return nil, fmt.Errorf("failed to open RQLite SQL connection: %w", err)
|
||||
}
|
||||
|
||||
// Configure connection pool with proper timeouts and limits
|
||||
db.SetMaxOpenConns(25) // Maximum number of open connections
|
||||
db.SetMaxIdleConns(5) // Maximum number of idle connections
|
||||
db.SetConnMaxLifetime(5 * time.Minute) // Maximum lifetime of a connection
|
||||
db.SetConnMaxIdleTime(2 * time.Minute) // Maximum idle time before closing
|
||||
|
||||
return &RQLiteAdapter{
|
||||
manager: manager,
|
||||
db: db,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user