Comments (5)
I ran into this issue yesterday. I managed to code around it, but it was less than ideal.
I ran into two primary issues:
- I inject the current user via an interface I've created.
- I was unable to inject my EF Core database context (and even if I could, there could be potential issues as EF Core DB Context is not meant to be run on multiple threads).
For the first issue, a web project could inject IHttpContextAccessor
, but my code is in a shared library that is used by both a web project and non-web projects. I worked around this by creating a type that functions similarly to HttpContextAccessor
, but for my interface that describes the current user instead.
I could have passed the user object into the feature manager method as a context, but then the calling code would need to know that the configured feature filters would need to act on the current user, and I don't believe that's a good idea.
For the second issue, I ended up injecting IServiceProvider
into my feature filters that need to access the database. This is a hack, in my opinion, and I hope to find another solution in the near future.
Both of these could have been avoided if the registered feature filters were not singletons (either scoped or transient would have sufficed).
The code-base seems pretty straight forward, but I don't want to make any bad assumptions. If you can give me some general direction (or at least tell me what you are trying to avoid), I can work on a PR to allow feature filters to not necessarily be singleton.
from featuremanagement-dotnet.
Is this different from existing behavior? I wouldn't expect a scoped service to be able to be used in the feature filters which are singletons. This is why things like IHttpContextAccessor
services exist which give a way to access the scoped HttpContext.
from featuremanagement-dotnet.
Closing since there has been no response. Please re-open if my response is inadequate.
from featuremanagement-dotnet.
I am hitting this too. I wish it could depend on a scoped ISessionManager.
from featuremanagement-dotnet.
I ran into this issue yesterday. I managed to code around it, but it was less than ideal.
I ran into two primary issues:
- I inject the current user via an interface I've created.
- I was unable to inject my EF Core database context (and even if I could, there could be potential issues as EF Core DB Context is not meant to be run on multiple threads).
For the first issue, a web project could inject
IHttpContextAccessor
, but my code is in a shared library that is used by both a web project and non-web projects. I worked around this by creating a type that functions similarly toHttpContextAccessor
, but for my interface that describes the current user instead.I could have passed the user object into the feature manager method as a context, but then the calling code would need to know that the configured feature filters would need to act on the current user, and I don't believe that's a good idea.
For the second issue, I ended up injecting
IServiceProvider
into my feature filters that need to access the database. This is a hack, in my opinion, and I hope to find another solution in the near future.Both of these could have been avoided if the registered feature filters were not singletons (either scoped or transient would have sufficed).
The code-base seems pretty straight forward, but I don't want to make any bad assumptions. If you can give me some general direction (or at least tell me what you are trying to avoid), I can work on a PR to allow feature filters to not necessarily be singleton.
This issue should be re-opened. @jimmyca15 @cbrianball @szalapski
from featuremanagement-dotnet.
Related Issues (20)
- Adding Instrumentation code
- Can I use Microsoft Feature Management – Feature Flags in other than .NET Core Frameworks ? HOT 1
- Local configuration and remote configuration HOT 2
- Unit Testing Custom Filter HOT 3
- Support of Targeting(percentage) and custom filter HOT 10
- How to Get All Feature Flags? HOT 10
- FeatureFilter not found exception HOT 4
- Infinite hang on configurationBuilder.Build() HOT 4
- CustomFilter breaks when upgrading to 2.6.0 with null reference exception HOT 5
- IgnoreMissingFeatureFilters should not be false by default HOT 5
- Authentication failed because the remote party has closed the transport stream HOT 2
- Using the CacheExpirationInterval option does not work on a console app HOT 4
- Feature Request: AddEndpointFilter for Minimal API's HOT 3
- Potential bug: Propagating App Service environment variables through IFeatureManager HOT 4
- is SDK cache persisted? HOT 2
- Feature flag with multiple custom filters HOT 5
- Feature Manager DI Scoping HOT 20
- Log level for missing feature declarations. HOT 2
- Adding version of public interface with generic parameters HOT 4
- Update docs with latest recommendations for defining and consuming feature flags HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from featuremanagement-dotnet.