basic API for Metalcon backend components
<dependency>
<groupId>de.metalcon</groupId>
<artifactId>api</artifactId>
<version>0.1.1</version>
</dependency>
The basic API is used in the API for your backend component.
To let the client (middleware) send requests to your backend component there are three pojects involved:
- API: basic Metalcon API defining response classes you can extend
<component>API
: component API based upon the basic API that (can) has additional requests and responses.
Until this point, there is no technology for transmission set.- middleware: client with a dispatcher that uses your component API to send requests and interpret responses.
- zmqWorker: worker living in your component that parses incoming requests and your responses and sends them to the client via ZeroMQ. The worker uses the basic API.
<component>
: your backend component used your API and the worker. It interprets incoming requests and delegates the responses to the worker.
Basic request class Request
that must be extended in order to use the worker.
Requests do not have any contraints yet.
Send the ShutdownRequest
to shutdown the transmission layer. (here: ZeroMQ Worker)
Basic response class Response
that must be extended in order to use the worker.
Responses have a status message at least:
- success: signalizes that the request was correct
- error: signalizes an error concerning the request in any layer, see
ErrorResponse
Simple response signalizing success if no additional information is needed.
Extend SuccessResponse
and add fields if you need them.
Basic error class ErrorResponse
that signalizes an error.
There are three types of errors, representing the layer in which the error occurred, defined in ErrorResponse.ErrorType
.
The error type and an error message describing the error must be set.
There is an optional solution field.
Error types:
- PARSING_ERROR: error occurred when parsing request/response objects
- INTERNAL_SERVER_ERROR: error occurred in server due to internal reasons
- USAGE_ERROR: error occurred in server due to misuse by client
Response signalizing a parsing error. Used by the worker that handles serialization/deserialization of requests and responses.
Response signalizing an internal server error.
Response signalizing a misuse by the client.