ikyriak / IdempotentAPI

A .NET library that handles the HTTP write operations (POST and PATCH) that can affect only once for the given request data and idempotency-key by using an ASP.NET Core attribute (filter).
MIT License
270 stars 39 forks source link

IdempotentAPI.DistributedAccessLock.MadelsonDistributedLock not found in NuGet repository #41

Closed TonyStarkGR closed 1 year ago

TonyStarkGR commented 1 year ago

Hello all, I wanted to use IdempotentAPI.DistributedAccessLock.MadelsonDistributedLock package as I'm facing issues with REST requests regarding duplicate entries, thus, I need the requests to be idempotent. However I can't find the specific package in the repository. Am I missing something ? should I look it up under a different name ? (the package title was copy-pasted from the code section)

Thank you in advance

ikyriak commented 1 year ago

Hello @TonyStarkGR,

Is this what you are looking for? https://www.nuget.org/packages/IdempotentAPI.DistributedAccessLock.MadelsonDistributedLock/2.0.0-rc-01

You can find all IdempotentAPI NuGet packages here.

Have a nice day,

TonyStarkGR commented 1 year ago

Good morning John, thank you for your reply. Most likely, although I see it's an RC and not a stable release. For now I went with https://github.com/madelson/DistributedLock Is it ok to proceed with this solution ? (based on your experience)

ikyriak commented 1 year ago

The idempotency in a Cluster Environment (i.e., a group of multiple server instances) using Distributed Locks is supported in IdempotentAPI v2.0.0 Release Candidate (RC), which also includes some bug fixes. However, the RC is two months old, and there are no known issues. So, if your project is in a cluster environment, you could try the IdempotentAPI v2.0.0 RC.

Yes, you could use the https://github.com/madelson/DistributedLock package directly and implement your idempotency logic/mechanism without using the IdempotentAPI package if this is simpler for your project.

TonyStarkGR commented 1 year ago

Thank you for you reply. Actually, I'm tying a combination of both, meaning that I use the Idempotent API to send the proper headers in each request and then I've used the https://github.com/madelson/DistributedLock inside the post/put requests implementation in the controller, meaning that all the DB insert and update operations are within spec. I did not create a custom logic. I just used the attributes as mentioned in the documentation and used a using clause to engulf the DB operations. Are there any other guides/tutorials or examples that I could refer to in order to get more in depth on the subject ?

ikyriak commented 1 year ago

That's great! You can read the following article. I recommend preparing fallback scenarios (based on your use case) when the lock cannot be acquired or distributed lock provider is not working. https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html