Skip to content

Conversation

jianoaix
Copy link
Contributor

@jianoaix jianoaix commented Feb 18, 2025

Why are these changes needed?

To make it easy and reliable to traverse the feed backward and forward in time

This PR changes the APIs to support this.

Note: the existing API is forward iteration, so forward mode works here already; but backward will need a change in DB layer (in a followup later)

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

c.JSON(http.StatusOK, response)

// TODO(jianxiao): this is just a placeholder as GetBlobMetadataByRequested is doing forward retrieval
blobs, nextCursor, err := s.blobMetadataStore.GetBlobMetadataByRequestedAt(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is TBD in followup

@@ -263,7 +263,8 @@ func (s *ServerV2) Start() error {
{
blobs := v2.Group("/blobs")
{
blobs.GET("/feed", s.FetchBlobFeed)
blobs.GET("/feed/forward", s.FetchBlobFeedForward)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't take a deep look into logic but is this simpler than just adding a query param to determine the direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks more clear to have separate APIs, but am open to merge them if these params can have clear semantics when they are used for both directions.

Copy link
Contributor Author

@jianoaix jianoaix Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(mostly parameters have to remain clear in semantics in both contexts, e.g. start and end makes sense in forward but not in backward any more)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking it more, maybe using before and after naturally addresses this, like

- direction: string  // "forward" or "backward"
- after: string     // exclusive lower bound
- before: string    // exclusive upper bound
- cursor: string    // if present, must be within (after, before)
- limit: int        // max items to return

For backward: fetches (after, cursor) in DESC order
For forward: fetches (cursor, before) in ASC order

@jianoaix jianoaix changed the title Make blob feed API into two-way APIs Support two-way traversal in blob feed API Feb 19, 2025
@jianoaix
Copy link
Contributor Author

ping?

@jianoaix jianoaix merged commit 0207000 into Layr-Labs:master Feb 20, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants