Class ResyncDetector
MeterNames.RESYNC counter for the two recovery cases.
The classification mirrors Flow's own server-side logic in
ServerRpcHandler#handleRpc, which is otherwise invisible to the kit
because the relevant ClientResentPayloadException and
ResynchronizationRequiredException are caught internally by
UidlRequestHandler and never surface to a
VaadinRequestInterceptor:
- Resync — the request carries
ApplicationConstants.RESYNCHRONIZE_ID= true. This is checked first because a resync request also carries a normally advancingclientId. - Resend — the request's
ApplicationConstants.CLIENT_TO_SERVER_IDis not greater than the last one seen for the same UI, i.e. the client re-sent a message the server had already processed (Flow compares againstlastProcessedClientToServerId + 1).
This is an approximation of Flow's own test. Flow only replays a cached
response when clientId == lastProcessedClientToServerId and
the message hash matches, discarding still-older ids as out-of-order. The
message hash is not exposed to the kit, so we cannot discriminate on it and
count every clientId <= previous as a resend; this may over-report
relative to what Flow actually replays.
The detector is stateless: the caller supplies the previously seen
clientId and stores the ResyncDetector.Result.lastClientId() returned here
(e.g. as an HTTP session attribute keyed by UI id), so there is no unbounded
per-session state held inside the kit.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumClassification of a single UIDL request.static final recordResult of classifying a request. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNoclientIdhas been seen yet for a UI. -
Constructor Summary
ConstructorsConstructorDescriptionResyncDetector(io.micrometer.core.instrument.MeterRegistry registry) Creates a detector recording into the given registry. -
Method Summary
Modifier and TypeMethodDescriptionClassifies a UIDL request body and records a counter for resend/resync events.
-
Field Details
-
NO_CLIENT_ID
public static final int NO_CLIENT_IDNoclientIdhas been seen yet for a UI.- See Also:
-
-
Constructor Details
-
ResyncDetector
public ResyncDetector(io.micrometer.core.instrument.MeterRegistry registry) Creates a detector recording into the given registry.- Parameters:
registry- the meter registry, notnull
-
-
Method Details
-
inspect
Classifies a UIDL request body and records a counter for resend/resync events.- Parameters:
requestBody- the raw UIDL request body (JSON); may benullor emptypreviousClientId- the lastclientIdseen for this UI, orNO_CLIENT_IDif none- Returns:
- the classification and the
clientIdto remember next
-