-
Notifications
You must be signed in to change notification settings - Fork 178
Narayana LRA API Notes
chalda edited this page Feb 16, 2021
·
1 revision
The Narayana LRA Coordinator comes with REST API which is defined by header Narayana-LRA-API-version
(defined at io.narayana.lra.LRAConstants
). These are few notes about changing the code of the Coordinator by changing the API behaviour.
There are not concrete rules on changing the code when a new API feature or functionality change is provided. It’s up to developer to write the code the best possible way.
But for the start there is expected similar pattern like following
Note
|
The verification of the highest supported API version could
be part of the ContainerRequestFilter /ContainerResponseFilter .
|
private static final APIVersion currentAPIVersion = APIVersion.instanceOf("2.0");
@GET
@Path("{LraId}/status")
public Response getLRAStatus((@HeaderParam("Narayana-LRA-API-version")
@DefaultValue("2.0") String version) {
APIVersion apiVersion = APIVersion.instanceOf(version);
if (apiVersion.compareTo(currentAPIVersion) > 0) {
// API version is bigger than the supported one
return Response.Status(EXPECTATION_FAILED)
.header(LRA_API_VERSION_HEADER_NAME, currentAPIVersion)
.build();
}
if (apiVersion.compareTo(currentAPIVersion) == 0) {
// the code for the newly added version 2.0
// which behaves differently than the older 1.x
} else {
// version is smaller than 2.0
// the behaviour for 1.x has to be still supported
}
}