@@ -18,12 +18,14 @@ const (
1818StickinessEnabledKey = "stickiness.enabled"
1919StickinessTypeKey = "stickiness.type"
2020StickinessLbCookieDurationSecondsKey = "stickiness.lb_cookie.duration_seconds"
21+ LoadBalancingAlgorithmTypeKey = "load_balancing.algorithm.type"
2122
2223DeregistrationDelayTimeoutSeconds = 300
2324SlowStartDurationSeconds = 0
2425StickinessEnabled = false
2526StickinessType = "lb_cookie"
2627StickinessLbCookieDurationSeconds = 86400
28+ LoadBalancingAlgorithmType = "round_robin"
2729)
2830
2931// Attributes represents the desired state of attributes for a target group.
@@ -55,6 +57,11 @@ type Attributes struct {
5557// considered stale. The range is 1 second to 1 week (604800 seconds). The
5658// default value is 1 day (86400 seconds).
5759StickinessLbCookieDurationSeconds int64
60+
61+ // LoadBalancingAlgorithmType: load_balancing.algorithm.type - The load balancing algorithm determines
62+ // how the load balancer selects targets when routing requests. The value is round_robin or
63+ // least_outstanding_requests. The default is round_robin.
64+ LoadBalancingAlgorithmType string
5865}
5966
6067func NewAttributes (attrs []* elbv2.TargetGroupAttribute ) (a * Attributes , err error ) {
@@ -64,6 +71,7 @@ func NewAttributes(attrs []*elbv2.TargetGroupAttribute) (a *Attributes, err erro
6471StickinessEnabled : StickinessEnabled ,
6572StickinessType : StickinessType ,
6673StickinessLbCookieDurationSeconds : StickinessLbCookieDurationSeconds ,
74+ LoadBalancingAlgorithmType : LoadBalancingAlgorithmType ,
6775}
6876var e error
6977for _ , attr := range attrs {
@@ -103,6 +111,11 @@ func NewAttributes(attrs []*elbv2.TargetGroupAttribute) (a *Attributes, err erro
103111if a .StickinessLbCookieDurationSeconds < 1 || a .StickinessLbCookieDurationSeconds > 604800 {
104112return a , fmt .Errorf ("%s must be within 1-604800 seconds, not %v" , attrKey , attrValue )
105113}
114+ case LoadBalancingAlgorithmTypeKey :
115+ a .LoadBalancingAlgorithmType = attrValue
116+ if attrValue != "round_robin" && attrValue != "least_outstanding_requests" {
117+ return a , fmt .Errorf ("invalid target group attribute value %s=%s" , attrKey , attrValue )
118+ }
106119default :
107120e = NewInvalidAttribute (attrKey )
108121}
@@ -180,6 +193,10 @@ func attributesChangeSet(a, b *Attributes) (changeSet []*elbv2.TargetGroupAttrib
180193changeSet = append (changeSet , tgAttribute (StickinessLbCookieDurationSecondsKey , fmt .Sprintf ("%v" , b .StickinessLbCookieDurationSeconds )))
181194}
182195
196+ if a .LoadBalancingAlgorithmType != b .LoadBalancingAlgorithmType {
197+ changeSet = append (changeSet , tgAttribute (LoadBalancingAlgorithmTypeKey , b .LoadBalancingAlgorithmType ))
198+ }
199+
183200return
184201}
185202
0 commit comments