restructuring of files. added 2 new methods(Asc, Desc) to field

This commit is contained in:
2025-10-18 12:31:46 +05:30
parent 6f5748d3d3
commit 325103e8ef
13 changed files with 433 additions and 446 deletions

24
pool.go
View File

@@ -7,8 +7,6 @@ import (
"context"
"errors"
"log/slog"
"strings"
"sync"
"sync/atomic"
"time"
@@ -17,17 +15,8 @@ import (
)
var (
poolPGX atomic.Pointer[pgxpool.Pool]
poolStringBuilder = sync.Pool{
New: func() any {
return new(strings.Builder)
},
}
poolPGX atomic.Pointer[pgxpool.Pool]
ErrConnStringMissing = errors.New("connection string is empty")
ErrInitTX = errors.New("failed to init db.tx")
ErrCommitTX = errors.New("failed to commit db.tx")
ErrNoRows = errors.New("no data found")
)
type Config struct {
@@ -77,17 +66,6 @@ func InitPool(conf Config) {
poolPGX.Store(p)
}
// get string builder from pool
func getSB() *strings.Builder {
return poolStringBuilder.Get().(*strings.Builder)
}
// put string builder back to pool
func putSB(sb *strings.Builder) {
sb.Reset()
poolStringBuilder.Put(sb)
}
// GetPool instance
func GetPool() *pgxpool.Pool {
return poolPGX.Load()