Skip to content

Commit

Permalink
fixup! Use endpoint as default connection option (ADR-119)
Browse files Browse the repository at this point in the history
  • Loading branch information
surminus committed Jan 8, 2025
1 parent 842bd77 commit ee7c1b1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ably/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ var defaultOptions = clientOptions{
LogLevel: LogWarning, // RSC2
}

var nonprodRegexp = regexp.MustCompile(`^nonprod:(.*)$`)

func defaultFallbackHosts() []string {
return endpointFallbacks("main", "ably-realtime.com")
}

func getEndpointFallbackHosts(endpoint string) []string {
if match := regexp.MustCompile(`^nonprod:(.*)$`).FindStringSubmatch(endpoint); match != nil {
if match := nonprodRegexp.FindStringSubmatch(endpoint); match != nil {
namespace := match[1]
return endpointFallbacks(namespace, "ably-realtime-nonprod.com")
}
Expand Down Expand Up @@ -504,7 +506,7 @@ func (opts *clientOptions) getEndpoint() string {
return endpoint
}

if match := regexp.MustCompile(`^nonprod:(.*)$`).FindStringSubmatch(endpoint); match != nil {
if match := nonprodRegexp.FindStringSubmatch(endpoint); match != nil {
namespace := match[1]
return fmt.Sprintf("%s.realtime.ably-nonprod.net", namespace)
}
Expand Down

0 comments on commit ee7c1b1

Please sign in to comment.