-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sigchain Class API should provide paginated ordered claims by returning Array-POJO and indexed access #327
Comments
This will also have implications for our |
In order to provide a "generic" paginated system. We have to change the It needs to take a
The above means that by default we are going to get Now this does mean you need to have an ID to actually be able to seek. However one could also "synthetically" construct a There's no limit, because it is an async generator enabling you to just stop consuming when you want to stop. Finally the whole thing is transactional too. The original method had the ability to filter to specific kinds of claims. This should be generalised to a general indexing filter. To do this, you would need the ability to filter the records according to index. However there will only be some items that are indexed, not all of them would be, and we would statically limit these. Examples of things to index to:
The third thing would be useful if you want to look up the most recent claim specified for a given When done like this, the function can get alot more complicated, because rather than iterating over all claims, they would instead iterate over a particular index. This is where a "general" query engine would be good, and that's what SQL was good for. However with a lack of a query engine here, we have to instead build a fixed set of indices that can be used. |
The return type is also We can follow this pattern across other domains too. Although I realise we haven't really standardised on "collection" iteration and seeking. Perhaps if custom indexing is required, one might move these into other functions since ultimately indexing in our key value system is going to be static. getClaims()
getClaimsByX() // where X is an index
getClaimsByNodeId
getClaimsByIdentityId Then this should translate to changes for |
In order to solve
|
Apparently we don't really use the seek/limit parameters that much. I think this is because this was a recent addition to the Points 2, and 3 should be done in #466. It seems that other places would be suitable as well to incorporate pagination parameters. |
For 2. make sure that the tests cover both |
ATM only the
|
We will need a new epic to deploy pagination-based streaming to all the relevant domain collection structures, and bubbling that up to the service handlers and CLI commands. That epic can incorporate point 1. |
We can hijack #237 for this general pagination deployment. |
Specification
The
Sigchain
API requires some rework as discovered here: #310 (comment)ChainData
andChainDataEncoded
types are record POJOs, which are not the right data type we should be returning to callers. Record POJOs do not preserve order, and when returning chain data, we would want to have the ability to iterate over the data, and it should be in the same order as the chain data (as ordered by the claim id).Array
. Record POJOs are not ordered. Alternatively to preserve both order and index access, aMap
can be used. HOWEVER,Array
and POJOs are pure data. TheMap
andSet
are not. This is why by convention, we only useMap
as a persistent rich construct, and when exchanging data between systems, we use arrays and POJOs.Sigchain.getChain
andSigchain.getChainEncoded
. Both methods should be returning the typeArray<Claim>
andArray<ClaimEncoded>
respectively. The encoded version is the base64ed JWT, but usually in our own application we would be working off theClaim
structure. At the same time there should be obvious conversion functions fromClaim
toClaimEncoded
and back.seek
andlimit
parameters to enable cursor pagination. Note thatseek
needs to be type of the seek key. The seek key ofSigchain
is theClaimId
. Which we know to be based onIdSortable
which itself uses timestamps internally. Both parameters are optional. One should be able to synthetically construct aClaimId
to represent a point in time cursor as well. This is a secondary priority, do this after the main design works.getClaim
which you can pass theClaimId
to acquire theClaim
itself. If they want an encoded version, we can exposegetClaimEncoded
.ChainData
andChainDataEncoded
may no longer be necessary as types. Just useArray<Claim>
andArray<ClaimEncoded>
. However it is essential that one can iterate over these 2 arrays, and be able to use extractors/transformers/converters to be able to acquire theClaimId
. This means theClaimId
must always be acquirable given aClaim
orClaimEncoded
, ideally efficiently.ClaimId
internally in our application andClaimIdString
only when using them as POJO keys. TheClaimIdEncoded
is purely used for external reference. And theClaim
should be usingClaimId
, andClaimEncoded
can useClaimIdEncoded
since you have to have JSON anyway. Make sure to use the reviver and replacer pattern as we do inside theStatus
class.Additional context
NodeManager
toNodeConnectionManager
#310 (comment) - Discussion about SigchainClaimId
,ClaimIdString
,ClaimIdEncoded
Sigchain
Tasks
The text was updated successfully, but these errors were encountered: