Coverage for src/hush_hush/_generated/api/health/ready.py: 0%

34 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-10-16 16:01 +0000

1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT. 

2 

3from http import HTTPStatus 

4from typing import Any 

5 

6import httpx 

7 

8from ... import errors 

9from ...client import AuthenticatedClient, Client 

10from ...models.ready import Ready 

11from ...types import Response 

12 

13 

14def _get_kwargs() -> dict[str, Any]: 

15 

16 _kwargs: dict[str, Any] = { 

17 "method": "get", 

18 "url": "/readyz", 

19 } 

20 

21 return _kwargs 

22 

23 

24def _parse_response( 

25 *, client: AuthenticatedClient | Client, response: httpx.Response 

26) -> Ready | None: 

27 if response.status_code == 200: 

28 response_200 = Ready.from_dict(response.json()) 

29 

30 return response_200 

31 

32 if response.status_code == 503: 

33 response_503 = Ready.from_dict(response.json()) 

34 

35 return response_503 

36 

37 if client.raise_on_unexpected_status: 

38 raise errors.UnexpectedStatus(response.status_code, response.content) 

39 else: 

40 return None 

41 

42 

43def _build_response( 

44 *, client: AuthenticatedClient | Client, response: httpx.Response 

45) -> Response[Ready]: 

46 return Response( 

47 status_code=HTTPStatus(response.status_code), 

48 content=response.content, 

49 headers=response.headers, 

50 parsed=_parse_response(client=client, response=response), 

51 ) 

52 

53 

54def sync_detailed( 

55 *, 

56 client: AuthenticatedClient | Client, 

57) -> Response[Ready]: 

58 """Readiness 

59 

60 Answers 200 when the database can serve a request and 503 when it 

61 can't, or when the server is shutting down. The container image's 

62 own health check asks this, so a container whose database has become 

63 unusable shows as unhealthy, where `/healthz` would stay green 

64 because the process is still up. Unauthenticated like `/healthz`, 

65 so a failure never says why - the reason goes to the server's log. 

66 

67 The database check is given 2 seconds and its answer is reused for 

68 about 3, so a burst of probes costs one database call and a hung 

69 database reads as not ready instead of hanging the probe. On 

70 SIGTERM the server answers 503 here at once and keeps serving for 3 

71 seconds before it stops accepting connections, so a load balancer 

72 stops sending traffic first and the requests already on their way 

73 aren't refused. `/healthz` stays 200 throughout. 

74 

75 Raises: 

76 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

77 httpx.TimeoutException: If the request takes longer than Client.timeout. 

78 

79 Returns: 

80 Response[Ready] 

81 """ 

82 

83 kwargs = _get_kwargs() 

84 

85 response = client.get_httpx_client().request( 

86 **kwargs, 

87 ) 

88 

89 return _build_response(client=client, response=response) 

90 

91 

92def sync( 

93 *, 

94 client: AuthenticatedClient | Client, 

95) -> Ready | None: 

96 """Readiness 

97 

98 Answers 200 when the database can serve a request and 503 when it 

99 can't, or when the server is shutting down. The container image's 

100 own health check asks this, so a container whose database has become 

101 unusable shows as unhealthy, where `/healthz` would stay green 

102 because the process is still up. Unauthenticated like `/healthz`, 

103 so a failure never says why - the reason goes to the server's log. 

104 

105 The database check is given 2 seconds and its answer is reused for 

106 about 3, so a burst of probes costs one database call and a hung 

107 database reads as not ready instead of hanging the probe. On 

108 SIGTERM the server answers 503 here at once and keeps serving for 3 

109 seconds before it stops accepting connections, so a load balancer 

110 stops sending traffic first and the requests already on their way 

111 aren't refused. `/healthz` stays 200 throughout. 

112 

113 Raises: 

114 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

115 httpx.TimeoutException: If the request takes longer than Client.timeout. 

116 

117 Returns: 

118 Ready 

119 """ 

120 

121 return sync_detailed( 

122 client=client, 

123 ).parsed 

124 

125 

126async def asyncio_detailed( 

127 *, 

128 client: AuthenticatedClient | Client, 

129) -> Response[Ready]: 

130 """Readiness 

131 

132 Answers 200 when the database can serve a request and 503 when it 

133 can't, or when the server is shutting down. The container image's 

134 own health check asks this, so a container whose database has become 

135 unusable shows as unhealthy, where `/healthz` would stay green 

136 because the process is still up. Unauthenticated like `/healthz`, 

137 so a failure never says why - the reason goes to the server's log. 

138 

139 The database check is given 2 seconds and its answer is reused for 

140 about 3, so a burst of probes costs one database call and a hung 

141 database reads as not ready instead of hanging the probe. On 

142 SIGTERM the server answers 503 here at once and keeps serving for 3 

143 seconds before it stops accepting connections, so a load balancer 

144 stops sending traffic first and the requests already on their way 

145 aren't refused. `/healthz` stays 200 throughout. 

146 

147 Raises: 

148 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

149 httpx.TimeoutException: If the request takes longer than Client.timeout. 

150 

151 Returns: 

152 Response[Ready] 

153 """ 

154 

155 kwargs = _get_kwargs() 

156 

157 response = await client.get_async_httpx_client().request(**kwargs) 

158 

159 return _build_response(client=client, response=response) 

160 

161 

162async def asyncio( 

163 *, 

164 client: AuthenticatedClient | Client, 

165) -> Ready | None: 

166 """Readiness 

167 

168 Answers 200 when the database can serve a request and 503 when it 

169 can't, or when the server is shutting down. The container image's 

170 own health check asks this, so a container whose database has become 

171 unusable shows as unhealthy, where `/healthz` would stay green 

172 because the process is still up. Unauthenticated like `/healthz`, 

173 so a failure never says why - the reason goes to the server's log. 

174 

175 The database check is given 2 seconds and its answer is reused for 

176 about 3, so a burst of probes costs one database call and a hung 

177 database reads as not ready instead of hanging the probe. On 

178 SIGTERM the server answers 503 here at once and keeps serving for 3 

179 seconds before it stops accepting connections, so a load balancer 

180 stops sending traffic first and the requests already on their way 

181 aren't refused. `/healthz` stays 200 throughout. 

182 

183 Raises: 

184 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

185 httpx.TimeoutException: If the request takes longer than Client.timeout. 

186 

187 Returns: 

188 Ready 

189 """ 

190 

191 return ( 

192 await asyncio_detailed( 

193 client=client, 

194 ) 

195 ).parsed