mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Rename composeURI func to composeMongoURI
To reflect that it's used exclusively for MongoDB (for now at least). Also added a descriptive comment to the function.
This commit is contained in:
committed by
Dan Christian Bogos
parent
f23179899c
commit
7eb78cb40e
@@ -111,7 +111,7 @@ func NewMongoStorage(host, port, db, user, pass, mrshlerStr string, cdrsIndexes
|
||||
isDataDB: isDataDB,
|
||||
counter: utils.NewCounter(time.Now().UnixNano(), 0),
|
||||
}
|
||||
uri := composeURI("mongodb", host, port, db, user, pass)
|
||||
uri := composeMongoURI("mongodb", host, port, db, user, pass)
|
||||
mongoStorage.ctxTTL = config.CgrConfig().DataDbCfg().QueryTimeout
|
||||
if !isDataDB {
|
||||
mongoStorage.ctxTTL = config.CgrConfig().StorDbCfg().QueryTimeout
|
||||
|
||||
@@ -1809,7 +1809,7 @@ func TestComposeURI(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
url := composeURI(tt.scheme, tt.host, tt.port, tt.db, tt.user, tt.pass)
|
||||
url := composeMongoURI(tt.scheme, tt.host, tt.port, tt.db, tt.user, tt.pass)
|
||||
if url != tt.expected {
|
||||
t.Errorf("expected %v,\nreceived %v", tt.expected, url)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,16 @@ func NewStorDBConn(dbType, host, port, name, user, pass, marshaler, sslmode stri
|
||||
return
|
||||
}
|
||||
|
||||
func composeURI(scheme, host, port, db, user, pass string) string {
|
||||
// composeMongoURI constructs a MongoDB URI from the given parameters:
|
||||
// - scheme: only "mongodb" for now.
|
||||
// - host: MongoDB server host (e.g., "localhost").
|
||||
// - port: MongoDB server port, excluded if "0".
|
||||
// - db: Database name, may include additional parameters (e.g., "db?retryWrites=true").
|
||||
// - user: Username for auth, omitted if empty.
|
||||
// - pass: Password for auth, only if username is set.
|
||||
//
|
||||
// TODO: Should probably remove scheme parameter, as only "mongodb" is supported.
|
||||
func composeMongoURI(scheme, host, port, db, user, pass string) string {
|
||||
uri := scheme + "://"
|
||||
if user != "" && pass != "" {
|
||||
uri += user + ":" + pass + "@"
|
||||
|
||||
Reference in New Issue
Block a user