@@ -68,11 +68,11 @@ func getPrimaryNonProdHost(root string) string {
68
68
}
69
69
70
70
func getEndpointFallbackHosts (endpoint string ) []string {
71
- if strings .HasPrefix (endpoint , "nonprod:" ) {
71
+ if strings .HasPrefix (endpoint , "nonprod:" ) { // REC2c3
72
72
root := strings .TrimPrefix (endpoint , "nonprod:" )
73
73
return endpointFallbacks (root , "ably-realtime-nonprod.com" )
74
74
}
75
- return endpointFallbacks (endpoint , "ably-realtime.com" )
75
+ return endpointFallbacks (endpoint , "ably-realtime.com" ) // REC2c4
76
76
}
77
77
78
78
// endpointFallbacks generates a list of fallback hosts based on the given namespace and root.
@@ -428,6 +428,7 @@ type clientOptions struct {
428
428
}
429
429
430
430
func (opts * clientOptions ) validate () error {
431
+ // REC1b1
431
432
if ! empty (opts .Endpoint ) && (! empty (opts .Environment ) || ! empty (opts .RealtimeHost ) || ! empty (opts .RESTHost ) || opts .FallbackHostsUseDefault ) {
432
433
err := errors .New ("invalid client option: cannot use endpoint with any of deprecated options environment, realtimeHost, restHost or FallbackHostsUseDefault" )
433
434
logger := opts .LogHandler
@@ -507,20 +508,21 @@ func isEndpointFQDN(endpoint string) bool {
507
508
return strings .Contains (endpoint , "." ) || strings .Contains (endpoint , "::" ) || endpoint == "localhost"
508
509
}
509
510
510
- // REC2
511
+ // REC1b
511
512
func (opts * clientOptions ) getHostnameFromEndpoint () string {
512
513
endpoint := opts .Endpoint
513
514
if empty (endpoint ) {
514
515
return defaultPrimaryHost
515
516
}
516
- if isEndpointFQDN (endpoint ) {
517
+ if isEndpointFQDN (endpoint ) { // REC1b2
517
518
return endpoint
518
519
}
520
+ // REC1b3
519
521
if strings .HasPrefix (endpoint , "nonprod:" ) {
520
522
root := strings .TrimPrefix (endpoint , "nonprod:" )
521
523
return getPrimaryNonProdHost (root )
522
524
}
523
- return getPrimaryProdHost (endpoint )
525
+ return getPrimaryProdHost (endpoint ) // REC1b4
524
526
}
525
527
526
528
func empty (s string ) bool {
@@ -556,12 +558,12 @@ func (opts *clientOptions) realtimeURL(realtimeHost string) (realtimeUrl string)
556
558
func (opts * clientOptions ) getFallbackHosts () ([]string , error ) {
557
559
if ! empty (opts .Endpoint ) {
558
560
if opts .FallbackHosts == nil {
559
- if isEndpointFQDN (opts .Endpoint ) {
561
+ if isEndpointFQDN (opts .Endpoint ) { // REC2c2
560
562
return opts .FallbackHosts , nil
561
563
}
562
564
return getEndpointFallbackHosts (opts .Endpoint ), nil
563
565
}
564
- return opts .FallbackHosts , nil
566
+ return opts .FallbackHosts , nil //REC2a2
565
567
}
566
568
567
569
logger := opts .LogHandler
@@ -583,7 +585,7 @@ func (opts *clientOptions) getFallbackHosts() ([]string, error) {
583
585
if opts .isProductionEnvironment () {
584
586
return defaultOptions .FallbackHosts , nil
585
587
}
586
- return getEndpointFallbackHosts (opts .Environment ), nil
588
+ return getEndpointFallbackHosts (opts .Environment ), nil // REC2c5
587
589
}
588
590
return opts .FallbackHosts , nil
589
591
}
0 commit comments