File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 2727__all__ = ("HTTPHealthCheck" , "HTTPHealthCheckIO" )
2828
2929
30+ DEFAULT_HEALTH_CHECK_INTERVAL_IN_SECONDS = 30
31+ DEFAULT_HEALTH_CHECK_TIMEOUT_IN_MILLISECONDS = 5000
32+
33+
3034class HTTPHealthCheckIO (BaseModel ):
3135 """
3236 Describe an HTTP-based health check.
@@ -44,8 +48,8 @@ class HTTPHealthCheckIO(BaseModel):
4448
4549 name : str = ""
4650 url : HttpUrl = ""
47- interval : int = 30
48- timeout : int = 5_000
51+ interval : int = DEFAULT_HEALTH_CHECK_INTERVAL_IN_SECONDS
52+ timeout : int = DEFAULT_HEALTH_CHECK_TIMEOUT_IN_MILLISECONDS
4953 headers : Dict [str , str ] = Field ({})
5054
5155
@@ -69,8 +73,8 @@ def __init__(
6973 * ,
7074 name : str = "" ,
7175 url : str = "" ,
72- interval : int = 30 ,
73- timeout : int = 5_000 ,
76+ interval : int = DEFAULT_HEALTH_CHECK_INTERVAL_IN_SECONDS ,
77+ timeout : int = DEFAULT_HEALTH_CHECK_TIMEOUT_IN_MILLISECONDS ,
7478 headers : Iterable = (),
7579 ** kwargs ,
7680 ):
@@ -81,3 +85,17 @@ def __init__(
8185 self .interval = interval
8286 self .timeout = timeout
8387 self .headers = dict (headers )
88+
89+ @classmethod
90+ def hydrate (
91+ cls ,
92+ io : HTTPHealthCheckIO ,
93+ ) -> "HTTPHealthCheck" :
94+ """Hydrate a new HTTPHealthCheck instance from its IO."""
95+ return cls (
96+ name = io .name ,
97+ url = io .url ,
98+ interval = io .interval ,
99+ timeout = io .timeout ,
100+ headers = io .headers ,
101+ )
You can’t perform that action at this time.
0 commit comments