Skip to content

Commit

Permalink
Merge pull request #973 from tegk/ifelseswitch
Browse files Browse the repository at this point in the history
Ifelseswitch
  • Loading branch information
kozlovic authored Nov 18, 2019
2 parents e9e2cd4 + 36cbb0e commit dd8a94c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1411,11 +1411,12 @@ func (s *StanServer) buildServerURLs() ([]string, error) {
// use 127.0.0.1 or ::1 for host address (important for
// Windows since connect with 0.0.0.0 or :: fails).
sport := strconv.Itoa(opts.Port)
if opts.Host == "0.0.0.0" {
switch opts.Host {
case "0.0.0.0":
hostport = net.JoinHostPort("127.0.0.1", sport)
} else if opts.Host == "::" || opts.Host == "[::]" {
case "::", "[::]":
hostport = net.JoinHostPort("::1", sport)
} else {
default:
hostport = net.JoinHostPort(opts.Host, sport)
}
}
Expand Down
9 changes: 6 additions & 3 deletions stores/pqdeadlines/pqdeadlines.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,26 @@ func (t deadlineDriver) Open(connection string) (driver.Conn, error) {
return nil, err
}
}

for _, keyVal := range strings.Fields(connection) {
s := strings.Split(keyVal, "=")
key := strings.ToLower(s[0])
if key == "readtimeout" {
switch key {
case "readtimeout":
readTimeout, err = time.ParseDuration(s[1])
if err != nil {
return nil, fmt.Errorf("unable to parse readTimeout: %v", err)
}
} else if key == "writetimeout" {
case "writetimeout":
writeTimeout, err = time.ParseDuration(s[1])
if err != nil {
return nil, fmt.Errorf("unable to parse writeTimeout: %v", err)
}
} else {
default:
connKeyVals = append(connKeyVals, keyVal)
}
}

connStr := strings.Join(connKeyVals, " ")
td := deadlineDialer{
readTimeout: readTimeout,
Expand Down
3 changes: 1 addition & 2 deletions stores/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,7 @@ func (s *SQLStore) createPreparedStmts() error {
func initSQLStmtsTable(driver string) {
// The sqlStmts table is initialized with MySQL statements.
// Update the statements for the selected driver.
switch driver {
case driverPostgres:
if driver == driverPostgres {
// Replace ? with $1, $2, etc...
for i, stmt := range sqlStmts {
n := 0
Expand Down

0 comments on commit dd8a94c

Please sign in to comment.