Coder Social home page Coder Social logo

Comments (4)

iyilm4z avatar iyilm4z commented on August 28, 2024 1

Roger that! Thank you very much for your detailed answer. I actually were expecting that you should use a key to store current tenant info like here. Now i understood that you did a simplified implementation of AsyncLocal for your presentation:)

from presentations.

hikalkan avatar hikalkan commented on August 28, 2024

Hi,

Do you mean "How to change current tenant?". If so, It's done with this.

from presentations.

iyilm4z avatar iyilm4z commented on August 28, 2024

Hi,
No i didn't mean that. As i understood of your talk, you said "Our application is stateless but we need to store the state of current tenant(even when we change it) after we receive the http request. Of course we musn't store it in a static variable(because it's not thread safe) but we must store it somewhere for per thread but where? The answer is AsyncLocal. We should store it by using AsyncLocal just like httpcontext internally does." I think that "storing part" is missing. The implementation of Ambient Context is missing. But you did it in ABP's this class. And you guys use it here with the help of scoping functionalty of DataContextAmbientScopeProvider. Please check out the video link on my first comment. You will understand what i meant because you yourself said that you forgot to implement that part.

from presentations.

hikalkan avatar hikalkan commented on August 28, 2024

AsyncLocal variable is here: https://github.com/hikalkan/presentations/blob/master/2018-04-06-Multi-Tenancy/src/MultiTenancyDraft/Infrastructure/TenantInfo.cs#L13 This stores the current tenant value for current web request.

Change method stores current tenant to the AsyncLocal variable, so it will be usable by the entire request.

Where/How the Change method is called? It's done in a middleware: https://github.com/hikalkan/presentations/blob/master/2018-04-06-Multi-Tenancy/src/MultiTenancyDraft/Infrastructure/MultiTenancyMiddleware.cs#L20

And finally the middleware is added to the asp.net core pipeline: https://github.com/hikalkan/presentations/blob/master/2018-04-06-Multi-Tenancy/src/MultiTenancyDraft/Startup.cs#L28

from presentations.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.