Intropy.IdempotencyService.Client 0.1.0

dotnet add package Intropy.IdempotencyService.Client --version 0.1.0
                    
NuGet\Install-Package Intropy.IdempotencyService.Client -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Intropy.IdempotencyService.Client" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Intropy.IdempotencyService.Client" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Intropy.IdempotencyService.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Intropy.IdempotencyService.Client --version 0.1.0
                    
#r "nuget: Intropy.IdempotencyService.Client, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Intropy.IdempotencyService.Client@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Intropy.IdempotencyService.Client&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Intropy.IdempotencyService.Client&version=0.1.0
                    
Install as a Cake Tool

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 exists
  • GetStatusAsync(MessageInfo messageInfo) - Check if a message should be processed or ignored
  • CommitAsync(MessageInfo messageInfo) - Commit a message record to mark it as processed

Models

  • MessageInfo - Contains component name, message ID, content hash, and timestamp
  • StatusResponse - Contains action (Proceed/Ignore) and reason
  • Action - Enum: Proceed or Ignore
  • Reason - 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

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 101 6/2/2026