Be Opinionated from the start
eByte23 opened this issue · 4 comments
Hi there,
Like your library however I feel It is quite confusing as it half heartedly opinionated.
A lot of the modules and things seem to be classes and not really configureable but you asking use to slightly configure things but they have to be done other wise it won't work.
Could we not just make these the defaults and clean my startup.cs?
E.g. TTenat : Class
Your asking we provided a tenant type cool, but then further along in your other middleware extra, your want the tenants Guid.
So would it not be better if we have an ITenant Interface
pubic interface ITenant
{
Guid Id { get; }
}
Then we know what we have from the start, this would potential make everything down the chain very easy.
For my use case I basically want per tenant: containers, db, hosting env.
To get this to work I add so much to my startup.cs but its just really what would be default code.
Could we it either very opinionated by default getting rid of this or not at all just seems weird.
If use your current setup you could make it opinionated by default and give a nice few lines of code like.
services.AddAspNetCoreMultiTenancy<Tenant>((options) =>
{
options
.AddPerTenantHostingEnvironment()
.ConfigurePerTenantServices((ser) =>
{
});
});
If you want to make Hosting environment area more configurable we could, allow users to choses were the tenant folders are located under the base path.
services.AddAspNetCoreMultiTenancy<Tenant>((options) =>
{
options
.AddPerTenantHostingEnvironment((envOptions) =>
{
envOptions.EnvironmentBase = ".tenants";
envOptions.WebRootBase = "www";
})
.ConfigurePerTenantServices((ser) =>
{
});
});
I do mean this come across constructive not destructively.
I'll add more later
@dazinator What happend to this project? Is this now discontinued?
I have some ideas on how to simplify the initial configuration with defaults that can basically be overriden. The idea is you could derive your startup class from a base startup class. I agree can be improved. However my focus at the moment is to make sure various scenarios in asp.net core 2 are supported (look at issues tab).
Project not dead, just not had much time of late. Still open for contributions, disussions, issues etc.
further along in your other middleware extra, your want the tenants Guid.
Yeah, its only the ConfigurePerTenantHostingEnvironment
that needs a GUID, and this need not necessarily be a property on the Tenant class, you could look it up from somewhere based on some tenant other tenant property, like a config file etc.
Also I am aware that not all use cases require per tenant environments, and I don't want to enforce a GUID on the tenant class if it is never required by anything, as that in itself could be confusing.
Will continue to think about it. Might be better to add an interface like IHaveHostingEnvironment
which enforces the GUID, then change the ConfigurePerTenantHostingEnvironment
to take that.
I can't really track this issue,i've taken your comments on board though, thanks for the feedback. Closing.