-
Notifications
You must be signed in to change notification settings - Fork 511
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: inject profile and session #2997
feat: inject profile and session #2997
Conversation
79e9c55
to
cffb1d5
Compare
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.
Looks good to me. I'd like to look at it closer for my own understanding, but multitenancy was the only problem last time.
This should help with unit testing, too?
@jamshale I hadn't thought about that but this could be used to inject test/mock dependencies in unit tests. We had strategies to do this already though so I'm not sure it changes too much. If we took advantage of this in more places, mocking dependencies would be simpler but that would require transitioning more places to using the injected profile. |
I've still got issues with entering a scope that isn't unique in the integration tests... I will take a deeper look. I'm beginning to question the value of the named scopes. ContextVars, for instance, don't name the contexts and require them to be globally unique. I'll look into that angle. |
I have to reassess the scopes after seeing there are still failures in the int tests
I removed named scopes entirely. They served no significant purpose in practice and they were causing all sorts of trouble. |
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.
I'm a bit confused why there was named scopes to begin with? If they didn't really do anything. But, I don't know the history of the project to have any opinion on it. It looks like a good change and that you know what you're doing, so I'm going to approve.
@jamshale Yeah, the tests implied that there was some perceived use to the named scopes at some point in the past but it looks like in practice they were just never really used. You could "recall" a particular scope by name and retrieve values out of it. But this would only ever be possible from a parent scope and it's just not common practice to, for example, obtain the bound values of a session from the profile scope that spawned it. That would probably be a bad idea, in fact lol. In practice, the lifetimes of the InjectionContexts and references to the contexts are, I think, appropriately narrow and naturally fall out of (lexical) scope at the right times. So we don't need to access the scopes by name since we're using the references to them as bound to a profile or session, etc. |
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
74e24c5
to
94d41be
Compare
Quality Gate passedIssues Measures |
This is yet another attempt at #2705 which was reverted in #2789 because of issues reported in #2777. This time, I have explicitly tested using the integration tests in the Multitenant provider plugin to ensure the same issue does not arise.
The same benefits mentioned in #2705 of course apply here. This makes it easier to provide pluggable components that depend on a Profile without the interface of those components accepting a profile in every method.
The primary difference between this PR and #2705 is that this ensures a unique scope based on wallet id of multi-tenant subwallets.
I have also tacked on injecting the session. This enables binding dependencies that require a session from plugins and other components. For instance, the DIDComm v2 work in #2959 could use this to bind a provider for the
SecretsAdapter
needed to provide access to Askar to the pack and unpack methods.