CRecordRegisterMicroService
This message is used to register microservices.
This message belongs to the microservice registry API.
{
"id": "be46c53e-e544-4e76-8c44-01f8c144254c",
"name": "REGISTER_MICRO_SERVICE",
"isNanoService": "false",
"description": "Register a microservice.",
"slots": [
{
"key": "1",
"name": "MICRO_SERVICE",
"direction": "REQUEST",
"presenceConstraint": "OPTIONAL",
"type": "RECORD",
"description": "The record of a single microservice to register."
},
{
"key": "2",
"name": "INSTANCE_ID",
"direction": "REQUEST",
"presenceConstraint": "OPTIONAL",
"type": "ID",
"description": "Optional: The instance ID."
},
{
"key": "3",
"name": "ADDRESS",
"direction": "REQUEST",
"presenceConstraint": "OPTIONAL",
"type": "TARGET_ADDRESS",
"description": "Optional: The address of the microservice instance."
}
]
}
Slot Description
| Key | Name | Direction | Presence Constraint | Type | Description |
|---|---|---|---|---|---|
| 1 | MICRO_SERVICE | REQUEST | false | RECORD | The record of a single microservice to register. |
| 2 | INSTANCE_ID | REQUEST | false | ID | Optional: The instance ID. |
| 3 | ADDRESS | REQUEST | false | TARGET_ADDRESS | Optional: The address of the microservice instance. |
Usage
Example of use (after generating of the class CRecordRegisterMicroService):
private void registerMicroservice(@NotNull final CTargetAddress aAddressOfMicroserviceRegistry,
@NotNull final IId aMicroserviceId,
@NotNull final String aDescription,
@NotNull final CRecord[] aAPI) throws CException
{
// aAPI is an array of records of type CRecordDescriptionOfRecord.
// This record type contains record IDs belonging to the API and a short description.
final CEnvelope env = CEnvelope.forSingleTarget(aAddressOfMicroserviceRegistry);
// data
final CRecord recDescription = CRecordMicroService.create();
CRecordMicroService.setId(recDescription,
aMicroserviceId);
CRecordMicroService.setDescription(recDescription,
aDescription);
CRecordMicroService.setApi(recDescription,
aAPI);
// create random instance ID
final IId instanceId = CIdFactory.randomOfType(EIdType.UUID);
// register data
final CRecord recRequest = CRecordRegisterMicroService.create();
CRecordRegisterMicroService.setAddress(recRequest,
getAddress());
CRecordRegisterMicroService.setInstanceId(recRequest,
instanceId);
CRecordRegisterMicroService.setMicroService(recRequest,
recDescription);
sendRequest(env,
recRequest);
}
Record Usage
In nyssr.net, we typically don't exchange interfaces between projects. Instead, we use platform-independent Records to describe message formats.
One or more descriptions of these Records are stored in the JSON or XML format
as record.json or record.xml within a directory.
The Record Generator, an included Swing tool, generates helper classes from these files.
These classes can then be used to type-safely write or read messages.