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

Reload/Refresh dynamically the app with UseBranchWithServices #166

Open
AmbroiseCouissin opened this issue Dec 22, 2018 · 0 comments
Open

Comments

@AmbroiseCouissin
Copy link

Hi!

I have been using UseBranchWithServices for quite sometime now and it is great.
I'm using it for multitenancy with IdentityServer4. One branch per tenant.

The problem I have is that I want to create new tenants dynamically without restarting the app.

For example, if I want to add new branches with newly created tenants every 15s, I could do something like this:

            Task.Run(async () =>
            {
                while (true)
                {
                    List<string> oldTenantIds = TenantIds ?? new List<string>();
                    TenantIds = GetTenants(db);
                    var tenantIdsToSubscribe = TenantIds.Except(oldTenantIds).ToList();
                    if (tenantIdsToSubscribe.Count != 0)
                        foreach (string tenantId in tenantIdsToSubscribe)
                            app.UseBranchWithServices($"/{tenantId}",
                                services => GenericServicesConfig(services, db, tenantId),
                                appBuilder => GenericAppBuilderConfig(appBuilder));

                    await Task.Delay(15000);
                }
            });

But this doesn't seem to work.

If I do this on startup without the Task.Run/while(true)/Task.Delay, it works.

Any idea?

Thanks!

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

No branches or pull requests

1 participant