-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add PinStatus.created and time-based pagination #39
Conversation
This adds creation timestamp which indicates when a pin request was registered at pinning service. `before` and `after` filters replace `skip` to enable time-based pagination over items in deterministic order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small language suggestions but otherwise this change looks reasonable to me and should improve determinism of results.
A few things on my mind here.
|
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
10 sounds perfect to me.
The biggest problem I see here is the new behavior of making the |
sgtm, set in 273d474
Good catch. We could either:
After thinking about it for a moment, I think (B) would be the cleanest and least error-prone way to tackle this. I don't believe any existing vendor supports pinning multiple CIDs in a single call, and unsure how valuable it would be to users anyway: if there is a need for that, one could simply create a DAG that has all of them and pin the root. |
A and B both seem like feasible options. B certainly seems to be the easiest to implement, and it also follows the pattern of only one CID operation happening at a time that is seen in the modify / delete endpoints. I think the spec could certainly be expanded to handle multiple requests in the future if we find that it's needed. |
Ok, the rule of thumb for this API is to simplify and remove complexity where possible. @lanzafame I tried to find some rationale for accepting multiple objects, but found none on github. |
It was simply a less requests the better thing, but v0.0.1 version didn't have the level of metadata creation associated with that clearly complicates how accepting an array actually plays out. |
Perhaps we should just keep I'm not opposed to limiting 1 pin per post, but that feels like the wrong solution for this problem. Is there a good reason to get rid of |
Only reason is to simplify API (replace offset-based pagination with value-based one). @obo20 any concerns with keeping |
If we want to keep the api surface low we could just drop |
@lidel the main concerns with skip go back to the initial issue we were having with our pinned records being separate from our "ongoing operations" records (queued, searching, failed). The biggest reason for this is that the majority of our users will directly pin content via an http upload (and not from the network). As such it didn't make sense to keep "successful" pins in the same location as pins that had no guarantee of succeeding. I obviously can't speak for other service providers but I wouldn't be surprised if others had a similar separation of their database records. We can certainly query both of these tables behind the scenes and then combine / parse the results before returning them to the user. However there's a few problems with this:
Skip would be possible if we were able to logically separate "pinned" objects from "ongoing" operations (queued, searching, failed). For reference, here are some of the options we discussed throughout various threads that would allow for offsets: A) Only allow querying for 1 status of pins at a time. (Cleanest, but could introduce extra calls to the API). B) Only allow for querying either "pinned" or "ongoing" statuses, but not both. (Less API calls but doesn't feel very clean to me) C) Have providers return a server error if they can't query both pinned / ongoing statuses at once (I would very much like to avoid this) D) Return an object with an array for each status queried. Like this:
There's a few different ways pagination would work for option D:
I'm personally l leaning towards Option A just because of how clean it is. |
Ok, did some thinking and realized we should be cognizant of developer experience here:
AFAIK we solved those footguns by removing 👉 In other words, I propose we merge this PR as-is. Below is my rationale. Why pagination with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the analysis, this approach looks reasonable to me and should be fairly easy to expand in the future as needed.
I added a suggestion about noting the caveat with the created time stamp for value based pagination if bulk creates are ever supported. Not required, but imo it makes it easier to avoid creating problems in the future.
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
9a5da19
to
d4e9e1e
Compare
Fix docs to match spec. The endpoint takes a single object now. Details: #39
This removes arrays and replaces them with single object in places which were missed before when we made the switch to single ops. Context: #39 (comment) Closes #46
This PR aims to address feedback about nondeterministic pagination, and inability to list pins created in specific time range:
PinStatus.created
timestamp which indicates when a pin request was registered at pinning service (queued)skip
parameter fromGET /pins
before
andafter
filters to enable time-based pagination over items in deterministic wayDOCS PREVIEW: https://ipfs.github.io/pinning-services-api-spec/#specUrl=https://raw.githubusercontent.com/ipfs/pinning-services-api-spec/feat/created-timestamp/ipfs-pinning-service.yaml
Closes #38 cc #12 @obo20 @GregTheGreek @priom @jsign @sanderpick @andrewxhill