Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

44
pkg/redis/client_pool.go Normal file
View File

@@ -0,0 +1,44 @@
package redis
import (
"sync"
)
func NewClientPool(args ...Pool) ClientPoolInterface {
result := &ClientPool{}
if len(args) > 0 {
result.pool = args[0]
}
return result
}
type ClientPoolInterface interface {
GetPool() Pool
SetPool(pool Pool)
GetFromPool() Client
}
type ClientPool struct {
oncePool sync.Once
pool Pool
}
func (f *ClientPool) GetPool() Pool {
f.oncePool.Do(func() {
if f.pool == nil {
f.pool = NewPool()
}
})
return f.pool
}
func (f *ClientPool) SetPool(pool Pool) {
f.pool = pool
}
func (f *ClientPool) GetFromPool() Client {
return NewClient(f.GetPool().Get())
}