Intropy.IdempotencyService.Client
0.1.2
dotnet add package Intropy.IdempotencyService.Client --version 0.1.2
NuGet\Install-Package Intropy.IdempotencyService.Client -Version 0.1.2
<PackageReference Include="Intropy.IdempotencyService.Client" Version="0.1.2" />
<PackageVersion Include="Intropy.IdempotencyService.Client" Version="0.1.2" />
<PackageReference Include="Intropy.IdempotencyService.Client" />
paket add Intropy.IdempotencyService.Client --version 0.1.2
#r "nuget: Intropy.IdempotencyService.Client, 0.1.2"
#:package Intropy.IdempotencyService.Client@0.1.2
#addin nuget:?package=Intropy.IdempotencyService.Client&version=0.1.2
#tool nuget:?package=Intropy.IdempotencyService.Client&version=0.1.2
Intropy Idempotency Service Client
A .NET client library for the Intropy Idempotency Service that uses Dapr service invocation for distributed message deduplication and idempotency checking.
Installation
dotnet add package Intropy.IdempotencyService.Client
Usage
Configuration with Dependency Injection
using Intropy.IdempotencyService.Client;
// In your Startup.cs or Program.cs
services.AddIdempotencyServiceClient(options =>
{
options.AppId = "idempotency-service"; // Dapr app ID of the target service
options.DaprHttpEndpoint = "http://localhost:3500"; // Optional: Local Dapr sidecar HTTP endpoint (default: http://localhost:3500)
});
Or configure using appsettings.json:
{
"IdempotencyService": {
"AppId": "idempotency-service",
"DaprHttpEndpoint": "http://localhost:3500"
}
}
services.AddIdempotencyServiceClient(Configuration);
Using the Client
using Intropy.IdempotencyService.Client;
using Intropy.IdempotencyService.Client.Models;
public class MyService
{
private readonly IIdempotencyServiceClient _idempotencyClient;
public MyService(IIdempotencyServiceClient idempotencyClient)
{
_idempotencyClient = idempotencyClient;
}
public async Task ProcessMessage(string component, string messageId, string messageContent)
{
// Check if message was already processed
var existingInfo = await _idempotencyClient.GetInfoAsync(component, messageId, CancellationToken.None);
if (existingInfo != null)
{
// Message was already processed
return;
}
// Create message info with hash of content
var messageInfo = new MessageInfo(
Component: component,
Id: messageId,
Hash: ComputeHash(messageContent),
Timestamp: DateTime.UtcNow
);
// Check if we should process this message
var status = await _idempotencyClient.GetStatusAsync(messageInfo);
if (status.Action == Action.Proceed)
{
// Process the message
await ProcessMessageInternal(messageContent);
// Commit the message to mark it as processed
await _idempotencyClient.CommitAsync(messageInfo);
}
else
{
// Message should be ignored
Console.WriteLine($"Ignoring message: {status.Reason}");
}
}
private string ComputeHash(string content)
{
using var sha256 = System.Security.Cryptography.SHA256.Create();
var bytes = System.Text.Encoding.UTF8.GetBytes(content);
var hash = sha256.ComputeHash(bytes);
return Convert.ToBase64String(hash);
}
}
API Reference
IIdempotencyServiceClient
GetInfoAsync(string component, string id, CancellationToken cancellationToken)- Retrieve message info if it existsGetStatusAsync(MessageInfo messageInfo)- Check if a message should be processed or ignoredCommitAsync(MessageInfo messageInfo)- Commit a message record to mark it as processed
Models
MessageInfo- Contains component name, message ID, content hash, and timestampStatusResponse- Contains action (Proceed/Ignore) and reasonAction- Enum: Proceed or IgnoreReason- Enum: NewerData, SameData, StaleData, or NoPreviousData
Requirements
- .NET 10.0 or later
- Dapr runtime with sidecar configured
- Access to the Idempotency Service via Dapr service invocation
Links
License
| 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
- Dapr.Client (>= 1.17.9)
- Intropy.Contracts (>= 0.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Http (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Intropy.IdempotencyService.Client:
| Package | Downloads |
|---|---|
|
Intropy.Framework.Components
Declarative Intropy components: a component class declares its identity, its rules and its steps, and the framework wires configuration, telemetry, Dapr, the platform-service clients, the endpoint and the publisher from the component's IntropyComponent attribute. |
GitHub repositories
This package is not used by any popular GitHub repositories.