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

add context to resolver #329

Merged
merged 4 commits into from
Mar 28, 2023
Merged

add context to resolver #329

merged 4 commits into from
Mar 28, 2023

Conversation

decentralgabe
Copy link
Member

unifies resolution interface between the sdk and service

@decentralgabe
Copy link
Member Author

will uptake #329 before merge

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2023

Codecov Report

Merging #329 (27fd2f9) into main (e6d9b21) will not change coverage.
The diff coverage is 92.31%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #329   +/-   ##
=======================================
  Coverage   57.16%   57.16%           
=======================================
  Files          51       51           
  Lines        6148     6148           
=======================================
  Hits         3514     3514           
  Misses       1974     1974           
  Partials      660      660           
Impacted Files Coverage Δ
did/key.go 72.87% <75.00%> (ø)
did/ion/operations.go 53.54% <100.00%> (ø)
did/peer.go 65.58% <100.00%> (ø)
did/pkh.go 73.10% <100.00%> (ø)
did/resolver.go 61.70% <100.00%> (ø)
did/web.go 70.34% <100.00%> (ø)

@decentralgabe decentralgabe added this to the BTC Miami milestone Mar 28, 2023
Copy link
Contributor

@andresuribe87 andresuribe87 left a comment

Choose a reason for hiding this comment

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

While you're here, couple more suggestions I have:

  • Rename the did.Resolution interface to did.Resolver. This makes it clear that anyone that implementers will need to implement Resolve.
  • Rename the did.Resolver struct to did.MultiMethodResolver.

@@ -46,7 +47,7 @@ func FuzzCreateAndResolve(f *testing.F) {
didKey, err := CreateDIDKey(kt, pubKey)
assert.NoError(t, err)

doc, err := resolver.Resolve(didKey.String())
doc, err := resolver.Resolve(context.TODO(), didKey.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere. Using TODO signals that the context isn't ready, or unavailable. Did you consider using Background()?

Suggested change
doc, err := resolver.Resolve(context.TODO(), didKey.String())
doc, err := resolver.Resolve(context.Background(), didKey.String())

Copy link
Member Author

Choose a reason for hiding this comment

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

historically I had used TODO for tests to signify it's not a real context, but happy to switch.

// ResolutionOptions https://www.w3.org/TR/did-spec-registries/#did-resolution-options
type ResolutionOptions any
// ResolutionOption https://www.w3.org/TR/did-spec-registries/#did-resolution-options
type ResolutionOption any
Copy link
Contributor

Choose a reason for hiding this comment

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

Whenever I see any, it's typically a symptom of an API that hasn't been fleshed out yet. In this case, it's unclear the shape of what ResolutionOption is acceptable by the functions that use it.

Instead, I would define an interface. Mind creating an issue to address?

Separately, This doesn't seem to be used anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah not used anywhere yet...will create an issue

Copy link
Member Author

Choose a reason for hiding this comment

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

@decentralgabe
Copy link
Member Author

addressed all comments - switched all TODO to Background

@decentralgabe decentralgabe merged commit a9e587d into main Mar 28, 2023
@decentralgabe decentralgabe deleted the add-ctx-resolution branch March 28, 2023 16:59
@decentralgabe decentralgabe self-assigned this Mar 28, 2023
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.

None yet

3 participants