Skip to content

Commit

Permalink
Add MongoDB Load Balancer support
Browse files Browse the repository at this point in the history
Add MongoDB Load Balancer support if specified in client uri connection string opts.
  • Loading branch information
ajclark authored Sep 17, 2024
1 parent d383d2b commit 9f6ed05
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion db/mongodb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,32 @@ func (c mongodbCreator) Create(p *properties.Properties) (ycsb.DB, error) {
}
caCertPool := x509.NewCertPool()
if ok := caCertPool.AppendCertsFromPEM(caCert); !ok {
log.Fatalf("certifacte %s could not be parsed", caFile)
log.Fatalf("certificate %s could not be parsed", caFile)
}

cliOpts.TLSConfig.RootCAs = caCertPool
}
}

// Check if the loadBalanced option is explicitly set
if connString.LoadBalancedSet {
// If loadBalanced is set, use its value
if connString.LoadBalanced {
log.Println("Setting loadBalanced to true")
cliOpts.SetLoadBalanced(true)
} else {
log.Println("Setting loadBalanced to false")
cliOpts.SetLoadBalanced(false)
}
} else {
// Default to false if not set
log.Println("Setting loadBalanced to false")
cliOpts.SetLoadBalanced(false)
}

t := uint64(p.GetInt64(prop.ThreadCount, prop.ThreadCountDefault))
cliOpts.SetMaxPoolSize(t)

username, usrExist := p.Get(mongodbUsername)
password, pwdExist := p.Get(mongodbPassword)
if usrExist && pwdExist {
Expand Down

0 comments on commit 9f6ed05

Please sign in to comment.