Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Change naming of DatabaseHostname to LocalHostname
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitzoz committed Feb 10, 2018
1 parent 34b5a4d commit e121d56
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) {

replica, err := lreplica.NewLocalReplica(
options.Replica.MaxBackgroundCopies,
options.Replica.DatabaseHostname,
options.Replica.LocalHostname,
strconv.Itoa(options.Replica.Port),
options.Replica.Username,
options.Replica.Password,
Expand Down
2 changes: 1 addition & 1 deletion strata/cmd/mongo/lreplica_drivers/lrldriver/lrldriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) {

replica, err := lreplica.NewLocalReplica(
options.Replica.MaxBackgroundCopies,
options.Replica.DatabaseHostname,
options.Replica.LocalHostname,
strconv.Itoa(options.Replica.Port),
options.Replica.Username,
options.Replica.Password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) {

replica, err := lreplica.NewLocalReplica(
options.Replica.MaxBackgroundCopies,
options.Replica.DatabaseHostname,
options.Replica.LocalHostname,
strconv.Itoa(options.Replica.Port),
options.Replica.Username,
options.Replica.Password,
Expand Down
4 changes: 2 additions & 2 deletions strata/cmd/mongo/lreplica_drivers/lrs3driver/lrs3driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type AWSOptions struct {

// ReplicaOptions are used for commands like backup and restore
type ReplicaOptions struct {
DatabaseHostname string `long:"database-hostname" default:"localhost" description:"Database hostname can be override with a specific hostname in most cases localhost is sufficient"`
LocalHostname string `long:"local-hostname" default:"localhost" description:"'localhost' or a hostname that is accessible on the local machine via e.g. kubernetes network"`
MaxBackgroundCopies int `long:"max-background-copies" default:"16" description:"Backup and restore actions will use up to this many goroutines to copy files"`
Port int `long:"port" default:"27017" description:"Backup should look for a mongod instance that is listening on this port"`
Username string `long:"username" description:"If auth is configured, specify the username with admin privileges here"`
Expand Down Expand Up @@ -72,7 +72,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) {
}
replica, err := lreplica.NewLocalReplica(
options.Replica.MaxBackgroundCopies,
options.Replica.DatabaseHostname,
options.Replica.LocalHostname,
strconv.Itoa(options.Replica.Port),
options.Replica.Username,
options.Replica.Password,
Expand Down
14 changes: 7 additions & 7 deletions strata/mongo/lreplica/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
)

type sessionGetter interface {
get(sslAllowInvalidCertificates bool, databaseHostname, port, username, password string) (*mgo.Session, error)
get(sslAllowInvalidCertificates bool, localHostname, port, username, password string) (*mgo.Session, error)
}

type localSessionGetter struct{}

// port could be the empty string
func (l *localSessionGetter) get(sslAllowInvalidCertificates bool, databaseHostname, port, username, password string) (*mgo.Session, error) {
addr := databaseHostname
func (l *localSessionGetter) get(sslAllowInvalidCertificates bool, localHostname, port, username, password string) (*mgo.Session, error) {
addr := localHostname
if port != "" {
addr += ":" + port
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func (l *localSessionGetter) get(sslAllowInvalidCertificates bool, databaseHostn
// LocalReplica is a replica where all methods that take a ReplicaID must be
// run on the host corresponding to ReplicaID
type LocalReplica struct {
databaseHostname string
localHostname string
port string
username string
password string
Expand All @@ -78,11 +78,11 @@ type LocalReplica struct {
}

// NewLocalReplica constructs a LocalReplica
func NewLocalReplica(maxBackgroundCopies int, databaseHostname, port, username, password string, sslAllowInvalidCertificates bool) (*LocalReplica, error) {
func NewLocalReplica(maxBackgroundCopies int, localHostname, port, username, password string, sslAllowInvalidCertificates bool) (*LocalReplica, error) {
return &LocalReplica{
sessionGetter: &localSessionGetter{},
maxBackgroundCopies: maxBackgroundCopies,
databaseHostname: databaseHostname,
localHostname: localHostname,
port: port,
username: username,
password: password,
Expand Down Expand Up @@ -198,7 +198,7 @@ func nestedBsonMapGet(m bson.M, arg string, moreArgs ...string) (interface{}, er
// TODO(agf): Have a way to pass in tags
func (r *LocalReplica) CreateSnapshot(replicaID, snapshotID string) (*strata.Snapshot, error) {
strata.Log("Getting session for CreateSnapshot()")
session, err := r.sessionGetter.get(r.sslAllowInvalidCertificates, r.databaseHostname, r.port, r.username, r.password)
session, err := r.sessionGetter.get(r.sslAllowInvalidCertificates, r.localHostname, r.port, r.username, r.password)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e121d56

Please sign in to comment.