Skip to content

Commit ee607d5

Browse files
authored
feat(lb): add new backend options : retries, redispatch, fastinter (#115)
1 parent 8cca469 commit ee607d5

File tree

6 files changed

+230
-0
lines changed

6 files changed

+230
-0
lines changed

scaleway-async/scaleway_async/lb/v1/api.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ async def create_backend(
910910
failover_host: Optional[str] = None,
911911
ssl_bridging: Optional[bool] = None,
912912
ignore_ssl_server_verify: Optional[bool] = None,
913+
redispatch_attempt_count: Optional[int] = None,
914+
max_retries: Optional[int] = None,
913915
) -> Backend:
914916
"""
915917
Create a backend in a given load balancer.
@@ -932,6 +934,8 @@ async def create_backend(
932934
:param failover_host: Scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. Do not include the scheme (eg https://).
933935
:param ssl_bridging: Defines whether to enable SSL between the Load Balancer and backend servers.
934936
:param ignore_ssl_server_verify: Defines whether the server certificate verification should be ignored.
937+
:param redispatch_attempt_count: Whether to use another backend server on each attempt.
938+
:param max_retries: Number of retries when a backend server connection failed.
935939
:return: :class:`Backend <Backend>`
936940
937941
Usage:
@@ -977,6 +981,8 @@ async def create_backend(
977981
failover_host=failover_host,
978982
ssl_bridging=ssl_bridging,
979983
ignore_ssl_server_verify=ignore_ssl_server_verify,
984+
redispatch_attempt_count=redispatch_attempt_count,
985+
max_retries=max_retries,
980986
),
981987
self.client,
982988
),
@@ -1036,6 +1042,8 @@ async def update_backend(
10361042
failover_host: Optional[str] = None,
10371043
ssl_bridging: Optional[bool] = None,
10381044
ignore_ssl_server_verify: Optional[bool] = None,
1045+
redispatch_attempt_count: Optional[int] = None,
1046+
max_retries: Optional[int] = None,
10391047
) -> Backend:
10401048
"""
10411049
Update a backend in a given load balancer.
@@ -1056,6 +1064,8 @@ async def update_backend(
10561064
:param failover_host: Scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. Do not include the scheme (eg https://).
10571065
:param ssl_bridging: Defines whether to enable SSL bridging between the Load Balancer and backend servers.
10581066
:param ignore_ssl_server_verify: Defines whether the server certificate verification should be ignored.
1067+
:param redispatch_attempt_count: Whether to use another backend server on each retries.
1068+
:param max_retries: Number of retries when a backend server connection failed.
10591069
:return: :class:`Backend <Backend>`
10601070
10611071
Usage:
@@ -1098,6 +1108,8 @@ async def update_backend(
10981108
failover_host=failover_host,
10991109
ssl_bridging=ssl_bridging,
11001110
ignore_ssl_server_verify=ignore_ssl_server_verify,
1111+
redispatch_attempt_count=redispatch_attempt_count,
1112+
max_retries=max_retries,
11011113
),
11021114
self.client,
11031115
),
@@ -1285,6 +1297,7 @@ async def update_health_check(
12851297
tcp_config: Optional[HealthCheckTcpConfig] = None,
12861298
http_config: Optional[HealthCheckHttpConfig] = None,
12871299
https_config: Optional[HealthCheckHttpsConfig] = None,
1300+
transient_check_delay: Optional[str] = None,
12881301
) -> HealthCheck:
12891302
"""
12901303
Update an health check for a given backend.
@@ -1316,6 +1329,7 @@ async def update_health_check(
13161329
13171330
One-of ('config'): at most one of 'mysql_config', 'ldap_config', 'redis_config', 'pgsql_config', 'tcp_config', 'http_config', 'https_config' could be set.
13181331
:param check_send_proxy: Defines whether proxy protocol should be activated for the health check.
1332+
:param transient_check_delay: Time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN).
13191333
:return: :class:`HealthCheck <HealthCheck>`
13201334
13211335
Usage:
@@ -1355,6 +1369,7 @@ async def update_health_check(
13551369
tcp_config=tcp_config,
13561370
http_config=http_config,
13571371
https_config=https_config,
1372+
transient_check_delay=transient_check_delay,
13581373
),
13591374
self.client,
13601375
),
@@ -3794,6 +3809,8 @@ async def create_backend(
37943809
failover_host: Optional[str] = None,
37953810
ssl_bridging: Optional[bool] = None,
37963811
ignore_ssl_server_verify: Optional[bool] = None,
3812+
redispatch_attempt_count: Optional[int] = None,
3813+
max_retries: Optional[int] = None,
37973814
) -> Backend:
37983815
"""
37993816
Create a backend for a given Load Balancer.
@@ -3817,6 +3834,8 @@ async def create_backend(
38173834
:param failover_host: Scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. Do not include the scheme (eg https://).
38183835
:param ssl_bridging: Defines whether to enable SSL between the Load Balancer and backend servers.
38193836
:param ignore_ssl_server_verify: Defines whether the server certificate verification should be ignored.
3837+
:param redispatch_attempt_count: Whether to use another backend server on each attempt.
3838+
:param max_retries: Number of retries when a backend server connection failed.
38203839
:return: :class:`Backend <Backend>`
38213840
38223841
Usage:
@@ -3860,6 +3879,8 @@ async def create_backend(
38603879
failover_host=failover_host,
38613880
ssl_bridging=ssl_bridging,
38623881
ignore_ssl_server_verify=ignore_ssl_server_verify,
3882+
redispatch_attempt_count=redispatch_attempt_count,
3883+
max_retries=max_retries,
38633884
),
38643885
self.client,
38653886
),
@@ -3918,6 +3939,8 @@ async def update_backend(
39183939
failover_host: Optional[str] = None,
39193940
ssl_bridging: Optional[bool] = None,
39203941
ignore_ssl_server_verify: Optional[bool] = None,
3942+
redispatch_attempt_count: Optional[int] = None,
3943+
max_retries: Optional[int] = None,
39213944
) -> Backend:
39223945
"""
39233946
Update a backend of a given Load Balancer.
@@ -3939,6 +3962,8 @@ async def update_backend(
39393962
:param failover_host: Scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. Do not include the scheme (eg https://).
39403963
:param ssl_bridging: Defines whether to enable SSL bridging between the Load Balancer and backend servers.
39413964
:param ignore_ssl_server_verify: Defines whether the server certificate verification should be ignored.
3965+
:param redispatch_attempt_count: Whether to use another backend server on each retries.
3966+
:param max_retries: Number of retries when a backend server connection failed.
39423967
:return: :class:`Backend <Backend>`
39433968
39443969
Usage:
@@ -3979,6 +4004,8 @@ async def update_backend(
39794004
failover_host=failover_host,
39804005
ssl_bridging=ssl_bridging,
39814006
ignore_ssl_server_verify=ignore_ssl_server_verify,
4007+
redispatch_attempt_count=redispatch_attempt_count,
4008+
max_retries=max_retries,
39824009
),
39834010
self.client,
39844011
),
@@ -4162,6 +4189,7 @@ async def update_health_check(
41624189
tcp_config: Optional[HealthCheckTcpConfig] = None,
41634190
http_config: Optional[HealthCheckHttpConfig] = None,
41644191
https_config: Optional[HealthCheckHttpsConfig] = None,
4192+
transient_check_delay: Optional[str] = None,
41654193
) -> HealthCheck:
41664194
"""
41674195
Update a health check for a given backend.
@@ -4194,6 +4222,7 @@ async def update_health_check(
41944222
41954223
One-of ('config'): at most one of 'mysql_config', 'ldap_config', 'redis_config', 'pgsql_config', 'tcp_config', 'http_config', 'https_config' could be set.
41964224
:param check_send_proxy: Defines whether proxy protocol should be activated for the health check.
4225+
:param transient_check_delay: Time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN).
41974226
:return: :class:`HealthCheck <HealthCheck>`
41984227
41994228
Usage:
@@ -4231,6 +4260,7 @@ async def update_health_check(
42314260
tcp_config=tcp_config,
42324261
http_config=http_config,
42334262
https_config=https_config,
4263+
transient_check_delay=transient_check_delay,
42344264
),
42354265
self.client,
42364266
),

scaleway-async/scaleway_async/lb/v1/marshalling.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ def unmarshal_HealthCheck(data: Any) -> HealthCheck:
404404
unmarshal_HealthCheckTcpConfig(field) if field is not None else None
405405
)
406406

407+
field = data.get("transient_check_delay")
408+
args["transient_check_delay"] = field
409+
407410
return HealthCheck(**args)
408411

409412

@@ -533,6 +536,9 @@ def unmarshal_Backend(data: Any) -> Backend:
533536
field = data.get("lb")
534537
args["lb"] = unmarshal_Lb(field) if field is not None else None
535538

539+
field = data.get("max_retries")
540+
args["max_retries"] = field
541+
536542
field = data.get("name")
537543
args["name"] = field
538544

@@ -545,6 +551,9 @@ def unmarshal_Backend(data: Any) -> Backend:
545551
field = data.get("proxy_protocol")
546552
args["proxy_protocol"] = field
547553

554+
field = data.get("redispatch_attempt_count")
555+
args["redispatch_attempt_count"] = field
556+
548557
field = data.get("send_proxy_v2")
549558
args["send_proxy_v2"] = field
550559

@@ -1341,6 +1350,7 @@ def marshal_HealthCheck(
13411350
"check_send_proxy": request.check_send_proxy,
13421351
"check_timeout": request.check_timeout,
13431352
"port": request.port,
1353+
"transient_check_delay": request.transient_check_delay,
13441354
}
13451355

13461356

@@ -1473,9 +1483,11 @@ def marshal_CreateBackendRequest(
14731483
else None,
14741484
"health_check": marshal_HealthCheck(request.health_check, defaults),
14751485
"ignore_ssl_server_verify": request.ignore_ssl_server_verify,
1486+
"max_retries": request.max_retries,
14761487
"name": request.name,
14771488
"on_marked_down_action": OnMarkedDownAction(request.on_marked_down_action),
14781489
"proxy_protocol": ProxyProtocol(request.proxy_protocol),
1490+
"redispatch_attempt_count": request.redispatch_attempt_count,
14791491
"send_proxy_v2": request.send_proxy_v2,
14801492
"server_ip": request.server_ip,
14811493
"ssl_bridging": request.ssl_bridging,
@@ -1715,9 +1727,11 @@ def marshal_UpdateBackendRequest(
17151727
if request.forward_protocol is not None
17161728
else None,
17171729
"ignore_ssl_server_verify": request.ignore_ssl_server_verify,
1730+
"max_retries": request.max_retries,
17181731
"name": request.name,
17191732
"on_marked_down_action": OnMarkedDownAction(request.on_marked_down_action),
17201733
"proxy_protocol": ProxyProtocol(request.proxy_protocol),
1734+
"redispatch_attempt_count": request.redispatch_attempt_count,
17211735
"send_proxy_v2": request.send_proxy_v2,
17221736
"ssl_bridging": request.ssl_bridging,
17231737
"sticky_sessions": StickySessionsType(request.sticky_sessions)
@@ -1810,6 +1824,7 @@ def marshal_UpdateHealthCheckRequest(
18101824
"check_send_proxy": request.check_send_proxy,
18111825
"check_timeout": request.check_timeout,
18121826
"port": request.port,
1827+
"transient_check_delay": request.transient_check_delay,
18131828
}
18141829

18151830

@@ -1942,9 +1957,11 @@ def marshal_ZonedApiCreateBackendRequest(
19421957
else None,
19431958
"health_check": marshal_HealthCheck(request.health_check, defaults),
19441959
"ignore_ssl_server_verify": request.ignore_ssl_server_verify,
1960+
"max_retries": request.max_retries,
19451961
"name": request.name,
19461962
"on_marked_down_action": OnMarkedDownAction(request.on_marked_down_action),
19471963
"proxy_protocol": ProxyProtocol(request.proxy_protocol),
1964+
"redispatch_attempt_count": request.redispatch_attempt_count,
19481965
"send_proxy_v2": request.send_proxy_v2,
19491966
"server_ip": request.server_ip,
19501967
"ssl_bridging": request.ssl_bridging,
@@ -2193,9 +2210,11 @@ def marshal_ZonedApiUpdateBackendRequest(
21932210
if request.forward_protocol is not None
21942211
else None,
21952212
"ignore_ssl_server_verify": request.ignore_ssl_server_verify,
2213+
"max_retries": request.max_retries,
21962214
"name": request.name,
21972215
"on_marked_down_action": OnMarkedDownAction(request.on_marked_down_action),
21982216
"proxy_protocol": ProxyProtocol(request.proxy_protocol),
2217+
"redispatch_attempt_count": request.redispatch_attempt_count,
21992218
"send_proxy_v2": request.send_proxy_v2,
22002219
"ssl_bridging": request.ssl_bridging,
22012220
"sticky_sessions": StickySessionsType(request.sticky_sessions)
@@ -2288,6 +2307,7 @@ def marshal_ZonedApiUpdateHealthCheckRequest(
22882307
"check_send_proxy": request.check_send_proxy,
22892308
"check_timeout": request.check_timeout,
22902309
"port": request.port,
2310+
"transient_check_delay": request.transient_check_delay,
22912311
}
22922312

22932313

scaleway-async/scaleway_async/lb/v1/types.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,16 @@ class Backend:
533533
Defines whether the server certificate verification should be ignored.
534534
"""
535535

536+
redispatch_attempt_count: Optional[int]
537+
"""
538+
Whether to use another backend server on each attempt.
539+
"""
540+
541+
max_retries: Optional[int]
542+
"""
543+
Number of retries when a backend server connection failed.
544+
"""
545+
536546

537547
@dataclass
538548
class BackendServerStats:
@@ -815,6 +825,11 @@ class HealthCheck:
815825
Defines whether proxy protocol should be activated for the health check.
816826
"""
817827

828+
transient_check_delay: Optional[str]
829+
"""
830+
Time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN).
831+
"""
832+
818833

819834
@dataclass
820835
class HealthCheckHttpConfig:
@@ -1933,6 +1948,16 @@ class CreateBackendRequest:
19331948
Defines whether the server certificate verification should be ignored.
19341949
"""
19351950

1951+
redispatch_attempt_count: Optional[int]
1952+
"""
1953+
Whether to use another backend server on each attempt.
1954+
"""
1955+
1956+
max_retries: Optional[int]
1957+
"""
1958+
Number of retries when a backend server connection failed.
1959+
"""
1960+
19361961

19371962
@dataclass
19381963
class GetBackendRequest:
@@ -2035,6 +2060,16 @@ class UpdateBackendRequest:
20352060
Defines whether the server certificate verification should be ignored.
20362061
"""
20372062

2063+
redispatch_attempt_count: Optional[int]
2064+
"""
2065+
Whether to use another backend server on each retries.
2066+
"""
2067+
2068+
max_retries: Optional[int]
2069+
"""
2070+
Number of retries when a backend server connection failed.
2071+
"""
2072+
20382073

20392074
@dataclass
20402075
class DeleteBackendRequest:
@@ -2189,6 +2224,11 @@ class UpdateHealthCheckRequest:
21892224
Defines whether proxy protocol should be activated for the health check.
21902225
"""
21912226

2227+
transient_check_delay: Optional[str]
2228+
"""
2229+
Time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN).
2230+
"""
2231+
21922232

21932233
@dataclass
21942234
class ListFrontendsRequest:
@@ -3405,6 +3445,16 @@ class ZonedApiCreateBackendRequest:
34053445
Defines whether the server certificate verification should be ignored.
34063446
"""
34073447

3448+
redispatch_attempt_count: Optional[int]
3449+
"""
3450+
Whether to use another backend server on each attempt.
3451+
"""
3452+
3453+
max_retries: Optional[int]
3454+
"""
3455+
Number of retries when a backend server connection failed.
3456+
"""
3457+
34083458

34093459
@dataclass
34103460
class ZonedApiGetBackendRequest:
@@ -3507,6 +3557,16 @@ class ZonedApiUpdateBackendRequest:
35073557
Defines whether the server certificate verification should be ignored.
35083558
"""
35093559

3560+
redispatch_attempt_count: Optional[int]
3561+
"""
3562+
Whether to use another backend server on each retries.
3563+
"""
3564+
3565+
max_retries: Optional[int]
3566+
"""
3567+
Number of retries when a backend server connection failed.
3568+
"""
3569+
35103570

35113571
@dataclass
35123572
class ZonedApiDeleteBackendRequest:
@@ -3661,6 +3721,11 @@ class ZonedApiUpdateHealthCheckRequest:
36613721
Defines whether proxy protocol should be activated for the health check.
36623722
"""
36633723

3724+
transient_check_delay: Optional[str]
3725+
"""
3726+
Time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN).
3727+
"""
3728+
36643729

36653730
@dataclass
36663731
class ZonedApiListFrontendsRequest:

0 commit comments

Comments
 (0)