Skip to content

Commit fad5319

Browse files
committed
Return Mega/Micro Service Version number at runtime
Signed-off-by: Tsai, Louie <[email protected]>
1 parent 8493659 commit fad5319

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ class ExampleService:
123123
self.megaservice.flow_to(embedding, llm)
124124
```
125125

126+
self.gateway = ChatQnAGateway(megaservice=self.megaservice, host="0.0.0.0", port=self.port)
127+
128+
````
129+
130+
## Check Mega/Micro Service health status and version number
131+
132+
Use below command to check Mega/Micro Service status.
133+
134+
```bash
135+
curl http://${your_ip}:${service_port}/v1/health_check\
136+
-X GET \
137+
-H 'Content-Type: application/json'
138+
````
139+
140+
Users should get output like below example if Mega/Micro Service works correctly.
141+
142+
```bash
143+
{"Service Title":"ChatQnAGateway/MicroService","Version":"1.0","Service Description":"OPEA Microservice Infrastructure"}
144+
```
145+
126146
## Contributing to OPEA
127147

128148
Welcome to the OPEA open-source community! We are thrilled to have you here and excited about the potential contributions you can bring to the OPEA platform. Whether you are fixing bugs, adding new GenAI components, improving documentation, or sharing your unique use cases, your contributions are invaluable.

comps/cores/mega/http_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def _create_app(self):
7272
)
7373
async def _health_check():
7474
"""Get the health status of this GenAI microservice."""
75-
return {"Service Title": self.title, "Service Description": self.description}
75+
from comps.version import __version__
76+
77+
return {"Service Title": self.title, "Version": __version__, "Service Description": self.description}
7678

7779
@app.get("/health")
7880
async def _health() -> Response:

tests/cores/mega/test_microservice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def test_add_route(self):
4747

4848
response = self.client.get("/v1/health_check")
4949
self.assertEqual(
50-
response.json(), {"Service Title": "s1", "Service Description": "OPEA Microservice Infrastructure"}
50+
response.json(),
51+
{"Service Title": "s1", "Version": "1.2", "Service Description": "OPEA Microservice Infrastructure"},
5152
)
5253

5354
response = self.client.get("/v1/sum")

0 commit comments

Comments
 (0)