Introduction
...
In the Basic Service example, we learned to perform a heartbeat check on a service, in order to monitor its health.
...
Code Block |
---|
language | bash |
---|
linenumbers | true |
---|
|
# go to examples/example03 and start the service
cd soajs.examples/example03/
# start the soajs example environment
sudo soajs services start --env=example
# export necessary environment variables to create local awareness
export SOAJS_ENV=EXAMPLE
export SOAJS_SRVPORT=4023
export SOAJS_DEPLOY_MANUAL=1
export SOAJS_REGISTRY_API=127.0.0.1:21000
# start service
node . |
The service is now running and listens on port 4023. Therefore, its maintenance port is 5023.
Next, a heartbeat request is sent to check the health of the service.
Code Block |
---|
language | bash |
---|
linenumbers | true |
---|
|
curl -X GET "http://127.0.0.1:5023/heartbeat" |
...
Tenant Name | Application Name | Access to Service | Access Type |
---|
Tenant example | EXAMP_BASIC | NO | NA |
Tenant example | EXAMP_3ZE08 | YES | FULL |
Tenant example | EXAMP_4H6CQ | YES | "buildName" |
An application is defined as the combination of a tenant and a package assigned to that tenant.
buildName using EXAMP_BASIC
Code Block |
---|
language | bash |
---|
title | Request |
---|
linenumbers | true |
---|
|
curl -X GET -H "key:4ea5db4c70b6168aeede6a8a56cb4624efdb6cb2cf3c7b88cbc1f5d97080a44f18083fa195e20dcc0b42496ae268ea91c657dd9b252b72de14c862e64f8522a9dbdaa1ce0f48ba2d5ed5eff49b47d0f728bddb2080c8cbc7bde3771116192b51" "http://127.0.0.1:20000/example03/buildName?lastName=Smith&access_token=valid_access_token" |
The key sent with the request is that generated for EXAMP_BASIC
The response to the request is shown below
Code Block |
---|
language | js |
---|
title | Response |
---|
linenumbers | true |
---|
|
{"result": false,"errors": {"codes": [154],"details": [{"code": 154,"message": "Access denied: The service is not available in your current package."}]}} |
buildName using EXAMP_3ZE08
Code Block |
---|
language | bash |
---|
title | Request |
---|
linenumbers | true |
---|
|
curl -X GET -H "key:4ea5db4c70b6168aeede6a8a56cb46246ca38b1b4f801f090d5821bd76b339e34b8ddb9ac2cb7ffee220cf3e463ac9cdf3902e91720c8f56684d7d88287affc0092eeb37648e7bde4f565f509b1b384127022bc2c1c1581f4ba50e28564d1c5c" "http://127.0.0.1:20000/example03/buildName?lastName=Smith&access_token=valid_access_token" |
The key sent with the request is that generated for EXAMP_3ZE08
Code Block |
---|
language | js |
---|
title | Response |
---|
linenumbers | true |
---|
|
{"result": true,"data": {"tenantName": "Client One","fullName": "John Smith"}} |
...
More importantly, the response containts the name of the tenant that requested the query.
...
testGet using EXAMP_
...
3ZE08
Code Block |
---|
language | bash |
---|
title | Request |
---|
linenumbers | true |
---|
|
curl -X GET "http://127.0.0.1:4000/example03/buildName?lastName=Thomas" -H "key:4ea5db4c70b6168aeede6a8a56cb4624079ff72a87d5174f5d880d546f326077dd82b8131322c2a5dbc02edec9d5ad7bfbfcf3730c2205850ffe7644e259ad2ee20280d25a1cfecdb7a62992920d2155cb30edffb6e53d49c528cc2e1ae54a6e" |
As expected, the response below indicates a positive response, with a correct answer for the user's query.
Code Block |
---|
language | js |
---|
title | Response |
---|
linenumbers | true |
---|
|
{"result": true,"data": {"tenantName": "Client Two","fullName": "John Thomas"}} |
testGet using EXAMP_3ZE08
Code Block |
---|
language | bash |
---|
title | Request |
---|
linenumbers | true |
---|
|
curl -X GET "4ea5db4c70b6168aeede6a8a56cb46246ca38b1b4f801f090d5821bd76b339e34b8ddb9ac2cb7ffee220cf3e463ac9cdf3902e91720c8f56684d7d88287affc0092eeb37648e7bde4f565f509b1b384127022bc2c1c1581f4ba50e28564d1c5c" "http://127.0.0.1:400020000/example03/testGet?lastName=Smith&firstName=John" -H "key:4ea5db4c70b6168aeede6a8a56cb46246ca38b1b4f801f090d5821bd76b339e34b8ddb9ac2cb7ffee220cf3e463ac9cdf3902e91720c8f56684d7d88287affc0092eeb37648e7bde4f565f509b1b384127022bc2c1c1581f4ba50e28564d1c5c"&access_token=valid_access_token" |
The response below contains the answer to the user's query.
Code Block |
---|
language | js |
---|
title | Response |
---|
linenumbers | true |
---|
|
{"result": true,"data": {"firstName": "John","lastName": "Smith"}} |
...
testGetusing EXAMP_4H6CQ
Code Block |
---|
language | bash |
---|
title | Request |
---|
linenumbers | true |
---|
|
curl -X GET -H "key:4ea5db4c70b6168aeede6a8a56cb4624079ff72a87d5174f5d880d546f326077dd82b8131322c2a5dbc02edec9d5ad7bfbfcf3730c2205850ffe7644e259ad2ee20280d25a1cfecdb7a62992920d2155cb30edffb6e53d49c528cc2e1ae54a6e" "http://127.0.0.1:400020000/example03/buildNametestGet?lastName=Smith&firstName=John&access_token=valid_access_token" |
The response to the request is shown below
...