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

Include optional Ipni-Cid-Schema-Type HTTP header #221

Merged
merged 5 commits into from
Sep 5, 2024
Merged

Conversation

gammazero
Copy link
Collaborator

@gammazero gammazero commented Aug 30, 2024

This optional header, when present, serves as an indication to advertisement publishers what type of data is being requested and is identified by the CID. This may help some publishers more quickly lookup the data.

The publisher, who receives the Ipni-Cid-Schema-Type HTTP header, does not validate the value, because newer values may need to be received by consumer that is using an older version of library.

Implements fix for ipni/storetheindex#2662

@gammazero gammazero requested a review from masih August 30, 2024 19:10
@willscott
Copy link
Member

github actions seems to be pretty unhappy about the references here - are you missing a file / definition?

This optional header, when present, serves as an indication to advertisement publishers what type of data is being requested and is identified by the CID. This may help some publishers more quickly lookup the data.

The publisher, who receives the Ipni-Cid-Schema-Type HTTP header, does not validate the value, because newer values may need to be received by consumer that is using an older version of library.

Implements fix for ipni/storetheindex#2662
Copy link
Member

@masih masih left a comment

Choose a reason for hiding this comment

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

Blockers:

  • exposed context key for schema type
  • check that returned node matches the expected type from link system.
  • match IPLD schema types exactly for header values.

Otherwise, LGTM. Left some suggestions.
Thank you for getting this done @gammazero 🍻

dagsync/ipnisync/cid_schema_hint.go Outdated Show resolved Hide resolved
dagsync/ipnisync/cid_schema_hint.go Outdated Show resolved Hide resolved
dagsync/ipnisync/cid_schema_hint.go Outdated Show resolved Hide resolved
dagsync/ipnisync/publisher.go Show resolved Hide resolved
dagsync/ipnisync/sync.go Outdated Show resolved Hide resolved
// Value already checked in Sync.
reqType, ok := ctx.Value(CidSchemaCtxKey).(string)
if ok {
req.Header.Set(CidSchemaHeader, reqType)
Copy link
Member

Choose a reason for hiding this comment

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

OK to set this for both request and response. We just want to make sure this is documented in the specs somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we want it in the response, do we, since the indexer knows what was requested?

dagsync/ipnisync/publisher.go Outdated Show resolved Hide resolved
Copy link
Member

@masih masih left a comment

Choose a reason for hiding this comment

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

There is a minor lint issue that's failing CI, otherwise no blockers. Thanks @gammazero 🚀

dagsync/ipnisync/cid_schema_hint.go Show resolved Hide resolved
@gammazero gammazero merged commit 63f8728 into main Sep 5, 2024
7 checks passed
@gammazero gammazero deleted the request-type-hint branch September 5, 2024 18:05
gammazero added a commit that referenced this pull request Sep 5, 2024
Same as #221 applied to Release-0.5.x branch.

- update go-libp2p to latest
gammazero added a commit that referenced this pull request Sep 5, 2024
Same as #221 applied to Release-0.5.x branch.

- update go-libp2p to latest
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