Skip to content

Commit a40ed33

Browse files
committed
fix: api docs
1 parent da4c5e3 commit a40ed33

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

hathor/healthcheck/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from dataclasses import dataclass
33
from datetime import datetime
44
from enum import Enum
5-
from typing import Any, Dict, List, Optional
5+
from typing import Any, Optional
66

77

88
class ComponentType(str, Enum):
@@ -37,7 +37,7 @@ class ComponentHealthCheck:
3737
def __post_init__(self) -> None:
3838
self.time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
3939

40-
def to_json(self) -> Dict[str, str]:
40+
def to_json(self) -> dict[str, str]:
4141
"""Return a dict representation of the object. All field names are converted to camel case."""
4242
json = {
4343
"componentType": self.component_type.value,
@@ -67,7 +67,7 @@ class ServiceHealthCheck:
6767
"""This class is used to store the result of a service health check."""
6868

6969
description: str
70-
checks: Dict[str, List[ComponentHealthCheck]]
70+
checks: dict[str, list[ComponentHealthCheck]]
7171

7272
@property
7373
def status(self) -> HealthCheckStatus:
@@ -98,7 +98,7 @@ def get_http_status_code(self) -> int:
9898
else:
9999
raise ValueError(f"Missing treatment for status {self.status}")
100100

101-
def to_json(self) -> Dict[str, Any]:
101+
def to_json(self) -> dict[str, Any]:
102102
"""Return a dict representation of the object. All field names are converted to camel case."""
103103
return {
104104
"status": self.status.value,

hathor/healthcheck/resources/healthcheck.py

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ def render_GET(self, request):
7474
Returns 503 otherwise. The response will contain the components that were considered for the healthcheck
7575
and the reason why they were unhealthy.
7676
77-
We currently perform 3 checks in the sync mechanism for the healthcheck:
77+
We currently perform 2 checks in the sync mechanism for the healthcheck:
7878
1. Whether the fullnode has recent block activity, i.e. if the fullnode has blocks with recent timestamps.
7979
2. Whether the fullnode has at least one synced peer
80-
3. Whether the other fullnodes in the network have a best block that is at most 10 blocks ahead of the fullnode's best block.
8180
''',
8281
'responses': {
8382
'200': {
@@ -90,14 +89,16 @@ def render_GET(self, request):
9089
'value': {
9190
'status': 'pass',
9291
'description': 'Hathor-core v0.56.0',
93-
'components': [
94-
{
95-
'componentName': 'sync',
96-
'componentType': 'internal',
97-
'status': 'pass',
98-
'output': 'Healthy'
99-
}
100-
]
92+
'checks': {
93+
'sync': [
94+
{
95+
'componentName': 'sync',
96+
'componentType': 'internal',
97+
'status': 'pass',
98+
'output': 'Healthy'
99+
}
100+
]
101+
}
101102
}
102103
}
103104
}
@@ -114,44 +115,50 @@ def render_GET(self, request):
114115
'value': {
115116
'status': 'fail',
116117
'description': 'Hathor-core v0.56.0',
117-
'components': [
118-
{
119-
'componentName': 'sync',
120-
'componentType': 'internal',
121-
'status': 'fail',
122-
'output': 'Node doesn\'t have recent blocks'
123-
}
124-
]
118+
'checks': {
119+
'sync': [
120+
{
121+
'componentName': 'sync',
122+
'componentType': 'internal',
123+
'status': 'fail',
124+
'output': 'Node doesn\'t have recent blocks'
125+
}
126+
]
127+
}
125128
}
126129
},
127130
'no_synced_peer': {
128131
'summary': 'Node with no synced peer',
129132
'value': {
130133
'status': 'fail',
131134
'description': 'Hathor-core v0.56.0',
132-
'components': [
133-
{
134-
'componentName': 'sync',
135-
'componentType': 'internal',
136-
'status': 'fail',
137-
'output': 'Node doesn\'t have a synced peer'
138-
}
139-
]
135+
'checks': {
136+
'sync': [
137+
{
138+
'componentName': 'sync',
139+
'componentType': 'internal',
140+
'status': 'fail',
141+
'output': 'Node doesn\'t have a synced peer'
142+
}
143+
]
144+
}
140145
}
141146
},
142147
'peer_best_block_far_ahead': {
143148
'summary': 'Peer with best block too far ahead',
144149
'value': {
145150
'status': 'fail',
146151
'description': 'Hathor-core v0.56.0',
147-
'components': [
148-
{
149-
'componentName': 'sync',
150-
'componentType': 'internal',
151-
'status': 'fail',
152-
'output': 'Node\'s peer with highest height is too far ahead.'
153-
}
154-
]
152+
'checks': {
153+
'sync': [
154+
{
155+
'componentName': 'sync',
156+
'componentType': 'internal',
157+
'status': 'fail',
158+
'output': 'Node\'s peer with highest height is too far ahead.'
159+
}
160+
]
161+
}
155162
}
156163
}
157164
}

0 commit comments

Comments
 (0)