Skip to content
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

feat: Use Indexing Service when feature flag is present #132

Merged
merged 9 commits into from
Dec 3, 2024

Conversation

Peeja
Copy link
Member

@Peeja Peeja commented Nov 26, 2024

storacha/project-tracking#140

Depends on storacha/blob-fetcher#19 and storacha/upload-service#57

When ff=indexing-service is given in the gateway URL, Freeway will use the Indexing Service to locate blobs.

@Peeja Peeja changed the title Use Indexing Service when feature flag is present feat: Use Indexing Service when feature flag is present Nov 26, 2024
* @returns {str is Ucanto.DID<Method>}
*/
const isDID = (str, method) =>
str.startsWith(`did:${method ? `${method}:` : ''}`)
Copy link
Member

Choose a reason for hiding this comment

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

You could use ucanto schema for this.

https://github.com/storacha/ucanto/blob/6de27c0f19790d9def1df2f2e299fa4f0996ded9/packages/core/src/schema/did.js#L8-L25

import { Schema } from '@ucanto/core'

Schema.did({ method }).is(str)

Copy link
Member Author

Choose a reason for hiding this comment

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

Aha! I couldn't figure out how to get that to work before. Not sure what wasn't clicking, but it all makes sense now. Pushed as Use Ucanto Schema.

src/util.js Outdated
ok: {
...locateResult.ok,
site: locateResult.ok.site.filter(
(site) => site.space && spaces.includes(site.space)
Copy link
Member

Choose a reason for hiding this comment

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

The space should be passed to the locator and used in the query to indexing service.

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, I forgot to switch this one to the new locator.scopeToSpaces(). Pushed!

}
}
}
? spaceScopedLocator(ctx.locator, [stubSpace])
Copy link
Member

Choose a reason for hiding this comment

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

What is a stubSpace?

Copy link
Member Author

Choose a reason for hiding this comment

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

A Space given as a stub (stub_space).

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha - for testing right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly—that's what this middleware is for.

package.json Outdated
@@ -51,17 +52,18 @@
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20231218.0",
"@storacha/cli": "^1.0.1",
"@storacha/client": "file:../upload-service/packages/w3up-client",
Copy link
Member

Choose a reason for hiding this comment

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

Needs update before merge.

Depending on how tests are run, the exception inside the promise can
blow things up. We intentionally want to ignore the error here, and just
test that it doesn't interfere with serving the data.
@Peeja Peeja merged commit fa3f480 into main Dec 3, 2024
1 check passed
@Peeja Peeja deleted the indexing-service branch December 3, 2024 17:20
fforbeck pushed a commit that referenced this pull request Dec 19, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.22.0](v2.21.0...v2.22.0)
(2024-12-19)


### Features

* egress client - ucanto integration
([#123](#123))
([22bed68](22bed68))
* enable egress tracking in production env
([#135](#135))
([ad43b62](ad43b62))
* **indexer:** probabilistic feature flag
([#136](#136))
([dca2b35](dca2b35))
* ucan invocation handler
([#133](#133))
([b199bfa](b199bfa))
* Use Indexing Service when feature flag is present
([#132](#132))
([fa3f480](fa3f480))


### Bug Fixes

* **config:** staging kv bidding
([#134](#134))
([7a523d5](7a523d5))
* **egress-client:** set nonce, expire and fix servedAt
([#130](#130))
([b135643](b135643))
* enable open telemetry for all envs
([#131](#131))
([c822465](c822465))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants