-
Notifications
You must be signed in to change notification settings - Fork 516
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: add timeout to did resolver resolve method #2464
feat: add timeout to did resolver resolve method #2464
Conversation
@@ -42,20 +43,28 @@ async def _resolve( | |||
profile: Profile, | |||
did: Union[str, DID], | |||
service_accept: Optional[Sequence[Text]] = None, | |||
*, | |||
timeout: Optional[int] = None, |
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.
why not initialize to 30 instead of None? That would make it more evident that the time-out default is 30 seconds.
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.
Fair question; using the optional enables expression that the timeout wasn't set. Since we call _resolve
from two other methods, and we want the timeout to apply to both and we want a default of 30 seconds when the timeout isn't set, we would have to set the default timeout to 30 on both the resolve
and resolve_with_metadata
methods or else make sure the timeout wasn't included in the call to _resolve
. It ends up being cleaner to set the default when timeout is None. But I think there's a middle ground. I'll put a constant on the class that has the default timeout value so it's clearer what it is and how it's used at a glance.
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.
LGTM.
Your logic around None
vs 30
makes sense, so works for me.
Signed-off-by: Daniel Bluhm <[email protected]>
Signed-off-by: Daniel Bluhm <[email protected]>
0690ad6
to
6ea611f
Compare
Kudos, SonarCloud Quality Gate passed! |
This PR adds a
timeout
parameter to the DID Resolver interface, defaulting to 30 seconds. Without it, a poorly behaved resolver plugin can "resolve" documents that aren't actually DID Docs and cause ACA-Py to run out of memory.There's space for additional tuning on the timeout default. Some DID Methods are, in my experience, quite slow (did:btcr and did:ion resolvers can be pretty slow sometimes). 30 seconds might be overly charitable.