Uniphar.Platform.Common
1.0.5
dotnet add package Uniphar.Platform.Common --version 1.0.5
NuGet\Install-Package Uniphar.Platform.Common -Version 1.0.5
<PackageReference Include="Uniphar.Platform.Common" Version="1.0.5" />
<PackageVersion Include="Uniphar.Platform.Common" Version="1.0.5" />
<PackageReference Include="Uniphar.Platform.Common" />
paket add Uniphar.Platform.Common --version 1.0.5
#r "nuget: Uniphar.Platform.Common, 1.0.5"
#:package Uniphar.Platform.Common@1.0.5
#addin nuget:?package=Uniphar.Platform.Common&version=1.0.5
#tool nuget:?package=Uniphar.Platform.Common&version=1.0.5
platform-dotnet-common
This repository contains common libraries and utilities for .NET applications used across various projects within the organization.
Locking across regions
Distributed locking allows for coordination between different regions/application instances to ensure that certain operations are performed in a mutually exclusive manner.
This is particularly useful - given Uniphar tech stack - to run dapr based applications in multiple regions
Internal application uses Cosmos document to record lock status and job assignments. Job is simply an id for the operation that is being performed and requires locking.
Locks are periodically renewed and assignments periodically refreshed to ensure that they remain valid and rebalanced. Configuration is provided via DistributedLockServiceOptions.
Usage
To instrument the locking in the app, service collection and service provider extension methods have been provided.
builder.Services.AddCosmosLockService("cosmos-connection-string");
Then as you build the app, you can initialize the lock service
await app.Services.InitializeDistributedLockAsync("region-designation", "cosmos-database-name", "cosmos-collection-name");
Once initialized, you can use the DistributedLockService to acquire and release locks. For example:
bool lockAcquired = await dls.AcquireJobLockAsync(context.JobId);
if (lockAcquired)
{
//lock acquired, proceed with job processing
}
else
{
// Failed to acquire the lease, another instance may be processing
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Azure.Cosmos (>= 3.56.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.1)
- Microsoft.Extensions.Logging (>= 10.0.1)
- Newtonsoft.Json (>= 13.0.4)
- Nito.AsyncEx (>= 5.1.2)
- Polly (>= 8.6.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.