diff --git a/load_balancing.go b/load_balancing.go index 00525545251..1a978b15ddd 100644 --- a/load_balancing.go +++ b/load_balancing.go @@ -22,6 +22,8 @@ type LoadBalancerPool struct { Monitor string `json:"monitor,omitempty"` Origins []LoadBalancerOrigin `json:"origins"` NotificationEmail string `json:"notification_email,omitempty"` + Latitude *float32 `json:"latitude,omitempty"` + Longitude *float32 `json:"longitude,omitempty"` // CheckRegions defines the geographic region(s) from where to run health-checks from - e.g. "WNAM", "WEU", "SAF", "SAM". // Providing a null/empty value means "all regions", which may not be available to all plan types. @@ -82,6 +84,7 @@ type LoadBalancer struct { // "geo" select pools based on RegionPools/PopPools // "dynamic_latency" select pools based on RTT (requires health checks) // "random" selects pools in a random order + // "proximity" select pools based on 'distance' from request // "" maps to "geo" if RegionPools or PopPools have entries otherwise "off" SteeringPolicy string `json:"steering_policy,omitempty"` } diff --git a/load_balancing_test.go b/load_balancing_test.go index 9928d658c3b..1a4beb1d28d 100644 --- a/load_balancing_test.go +++ b/load_balancing_test.go @@ -26,6 +26,8 @@ func TestCreateLoadBalancerPool(t *testing.T) { "name": "primary-dc-1", "enabled": true, "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc", + "latitude": 55, + "longitude": -12.5, "origins": [ { "name": "app-server-1", @@ -58,6 +60,8 @@ func TestCreateLoadBalancerPool(t *testing.T) { "enabled": true, "minimum_origins": 1, "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc", + "latitude": 55, + "longitude": -12.5, "origins": [ { "name": "app-server-1", @@ -79,6 +83,10 @@ func TestCreateLoadBalancerPool(t *testing.T) { }`) } + fptr := func(f float32) *float32 { + return &f + } + mux.HandleFunc("/user/load_balancers/pools", handler) createdOn, _ := time.Parse(time.RFC3339, "2014-01-01T05:20:00.12345Z") modifiedOn, _ := time.Parse(time.RFC3339, "2014-02-01T05:20:00.12345Z") @@ -91,6 +99,8 @@ func TestCreateLoadBalancerPool(t *testing.T) { Enabled: true, MinimumOrigins: 1, Monitor: "f1aba936b94213e5b8dca0c0dbf1f9cc", + Latitude: fptr(55), + Longitude: fptr(-12.5), Origins: []LoadBalancerOrigin{ { Name: "app-server-1", @@ -112,6 +122,8 @@ func TestCreateLoadBalancerPool(t *testing.T) { Name: "primary-dc-1", Enabled: true, Monitor: "f1aba936b94213e5b8dca0c0dbf1f9cc", + Latitude: fptr(55), + Longitude: fptr(-12.5), Origins: []LoadBalancerOrigin{ { Name: "app-server-1",