Skip to content

Commit

Permalink
Merge pull request #651 from tpolich/load_balancer_proximity_steering
Browse files Browse the repository at this point in the history
Support for Latitude/Longitude on pools for Proximity Steering
  • Loading branch information
jacobbednarz authored Jun 3, 2021
2 parents 958d60e + 1740533 commit c312ea5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions load_balancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"`
}
Expand Down
12 changes: 12 additions & 0 deletions load_balancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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")
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit c312ea5

Please sign in to comment.