Class FallbackPageToken
java.lang.Object
tech.ydb.yoj.repository.db.list.token.FallbackPageToken
- All Implemented Interfaces:
PageToken
Page token which eases migration from one token implementation (fallback) to another (primary).
It attempts to decode page token first using primary implementation, and, failing that, using the fallback;
and can encode listing results using either fallback or primary, depending on the value of
encodeAsPrimary flag.
Changing old token implementation oldImpl to new implementation newImpl should go as follows:
- Deploy the app using
FallbackPageToken(primary=newImpl, fallback=oldImpl, encodeAsPrimary=false)so that all app instances encode listing results using the least common denominator,oldImpl. - Deploy the app using
FallbackPageToken(primary=newImpl, fallback=oldImpl, encodeAsPrimary=true). Old tokens can still be decoded, but all app instances will encode their listing results usingnewImpl. - Deploy new application version using
newImplonly, because no app instances useoldImplto encode listing results any more.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> ListRequest.Builder<T>decode(ListRequest.Builder<T> bldr, @NonNull String token) Decodes page token into listing request.
This method must be called only once per page, because it changes the listing request builder's state and is therefore non-idempotent.<T,R> String encode(@NonNull GenericListResult<T, R> result) Encodes information about next search result page.
-
Constructor Details
-
FallbackPageToken
public FallbackPageToken()
-
-
Method Details
-
encode
Description copied from interface:PageTokenEncodes information about next search result page. -
decode
@NonNull public <T> ListRequest.Builder<T> decode(@NonNull ListRequest.Builder<T> bldr, @NonNull @NonNull String token) throws BadListingException.InvalidPageToken Description copied from interface:PageTokenDecodes page token into listing request.
This method must be called only once per page, because it changes the listing request builder's state and is therefore non-idempotent.- Specified by:
decodein interfacePageToken- Type Parameters:
T- search request type- Parameters:
bldr- listing request buildertoken- page token- Returns:
- listing request builder for to the page encoded by the token
- Throws:
BadListingException.InvalidPageToken- page token is invalid
-