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: inject profile and session #2997

Merged
merged 3 commits into from
May 31, 2024

Conversation

dbluhm
Copy link
Contributor

@dbluhm dbluhm commented May 29, 2024

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.

@dbluhm dbluhm requested a review from jamshale May 29, 2024 02:47
@dbluhm dbluhm force-pushed the feature/inject-profile-redo branch from 79e9c55 to cffb1d5 Compare May 29, 2024 02:48
jamshale
jamshale previously approved these changes May 29, 2024
Copy link
Contributor

@jamshale jamshale left a 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?

@dbluhm
Copy link
Contributor Author

dbluhm commented May 29, 2024

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.

@dbluhm
Copy link
Contributor Author

dbluhm commented May 29, 2024

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.

@jamshale jamshale self-requested a review May 29, 2024 16:49
@dbluhm dbluhm dismissed jamshale’s stale review May 29, 2024 16:52

I have to reassess the scopes after seeing there are still failures in the int tests

@dbluhm dbluhm marked this pull request as draft May 29, 2024 16:52
@dbluhm dbluhm marked this pull request as ready for review May 29, 2024 23:58
@dbluhm
Copy link
Contributor Author

dbluhm commented May 29, 2024

I removed named scopes entirely. They served no significant purpose in practice and they were causing all sorts of trouble.

Copy link
Contributor

@jamshale jamshale left a 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.

@dbluhm
Copy link
Contributor Author

dbluhm commented May 30, 2024

@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.

@dbluhm dbluhm force-pushed the feature/inject-profile-redo branch from 74e24c5 to 94d41be Compare May 31, 2024 19:18
@dbluhm dbluhm enabled auto-merge May 31, 2024 19:20
@dbluhm dbluhm merged commit 854b7a5 into openwallet-foundation:main May 31, 2024
7 checks passed
Copy link

sonarcloud bot commented May 31, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@dbluhm dbluhm deleted the feature/inject-profile-redo branch May 31, 2024 23:32
@jamshale jamshale mentioned this pull request Jul 23, 2024
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