Collie 1.0.10
See the version list below for details.
dotnet add package Collie --version 1.0.10
NuGet\Install-Package Collie -Version 1.0.10
<PackageReference Include="Collie" Version="1.0.10" />
paket add Collie --version 1.0.10
#r "nuget: Collie, 1.0.10"
// Install Collie as a Cake Addin
#addin nuget:?package=Collie&version=1.0.10
// Install Collie as a Cake Tool
#tool nuget:?package=Collie&version=1.0.10
Collie
Inversion of Control Container
Purpose
Collie is a multi-tenant inversion of control container for .NET 5 & above. Multi-tenancy is supported by introducing the concept of a tenant key, that defines the shared context which a given scope should use to resolve the TenantSingleton service lifetime (one shared instance per tenant).
Usage
Collie offers interoperability with the standard .NET dependency injection API. However, to support the enhanced tenancy features, a native API is also provided.
For the most basic use case, a ServiceCollection can be populated, and an IServiceProvider built as shown below.
int tenantId = 0;
var services = new ServiceCollection();
services.AddSingleton<IServiceA, DefaultServiceA>();
services.AddTenantSingleton<IServiceB, DefaultServiceB>();
services.AddScoped<Tuple<int>>(container => new Tuple<int>(tenantId++));
IServiceContainer rootContainer = services.BuildCollieProvider(catalog, container => container.GetService<Tuple<int>>(), typeof(Tuple<int>));
var scopedProvider = rootContainer.CreateScope().ServiceProvider;
For more advanced usage via the Collie API, see the unit test suite.
Scalability
One of the key challenges that arises when dealing with (potentially massive) multi-tenancy is determining exactly how long the TenantSingleton lifetime should persist. In the nominal case, where there are relatively few clients, TenantSingletons should live effectively as long as a Singleton, which is to say until the root IServiceProvider is disposed. However, as the number of tenants rises, so too does the memory overhead required to retain all TenantSingletons. Consequently, at some point, it becomes desireable to dispose of tenant state not currently in active use. Using Collie's native API, this can be achieved by specifying a TenantCacheSize. This controls the desired number of tenant contexts to retain in memory when no requests are active. When requests are active, the actual number retained may be higher if needed to service all active requests.
Background
While Collie derives its name from the breed known for their ability to fetch, it also pays tribute to a childhood friend who later tragically disappeared under suspicious circumstances. Still hoping you're out there and find your way home.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- Collie.Abstractions (>= 1.0.10)
- Collie.Compatibility.Abstractions (>= 1.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Collie:
Package | Downloads |
---|---|
Collie.Compatibility
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.2 | 118 | 9/30/2023 |
2.2.1 | 118 | 8/29/2023 |
2.2.0 | 144 | 8/29/2023 |
2.1.0 | 150 | 7/15/2023 |
2.0.0 | 435 | 10/30/2022 |
1.2.0 | 502 | 7/17/2022 |
1.1.0 | 535 | 7/3/2022 |
1.0.11 | 515 | 6/30/2022 |
1.0.10 | 512 | 6/7/2022 |
1.0.9 | 502 | 6/4/2022 |
1.0.8 | 519 | 5/29/2022 |
1.0.7 | 501 | 5/28/2022 |
1.0.6 | 522 | 5/28/2022 |
1.0.4 | 518 | 5/12/2022 |
1.0.3 | 359 | 5/12/2022 |
1.0.2 | 363 | 5/12/2022 |
1.0.1 | 355 | 5/12/2022 |
1.0.0 | 363 | 5/12/2022 |