All Projects → guitsaru → rack-idempotency

guitsaru / rack-idempotency

Licence: MIT License
Rack middleware for idempotency guarantees in mutating endpoints.

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to rack-idempotency

Rack Attack
Rack middleware for blocking & throttling
Stars: ✭ 5,012 (+24960%)
Mutual labels:  rack, rack-middleware
rack-session-smart cookie
Slightly smarter session cookies for Rack 2 apps
Stars: ✭ 43 (+115%)
Mutual labels:  rack, rack-middleware
rack-cargo
🚚 Batch requests for Rack apps (works with Rails, Sinatra, etc)
Stars: ✭ 17 (-15%)
Mutual labels:  rack, rack-middleware
rack-params
`Rack::Request.params` validation and type coercion, on Rack.
Stars: ✭ 31 (+55%)
Mutual labels:  rack
detectify
Detectify is a gem for multi-tenant Rack apps, to help you retrieve domain and subdomain-related data from a database.
Stars: ✭ 79 (+295%)
Mutual labels:  rack
hapic
Input/Output/Error management for your python controllers with Swagger doc generation
Stars: ✭ 18 (-10%)
Mutual labels:  api-server
foxx-builder
ArangoDB Foxx Services in a super intuitive way
Stars: ✭ 22 (+10%)
Mutual labels:  api-server
endpoints
Lightweight REST api backend framework that automatically maps urls to python modules and classes
Stars: ✭ 30 (+50%)
Mutual labels:  api-server
rudder
RESTful API Proxy for Helm
Stars: ✭ 60 (+200%)
Mutual labels:  api-server
one
🚥 Idempotency Handler, for making sure incoming requests are idempotent. Useful for payments, "at least once delivery" systems and more.
Stars: ✭ 18 (-10%)
Mutual labels:  idempotent
Magento-Extra-RESTful
Many more REST resources for Magento's API
Stars: ✭ 32 (+60%)
Mutual labels:  api-server
laravel-5.7-email-verification-and-auth-via-api
Laravel 5.7 Email verification and Authentication via API
Stars: ✭ 22 (+10%)
Mutual labels:  api-server
maverick
Web API framework with a need for speed
Stars: ✭ 14 (-30%)
Mutual labels:  api-server
ExpressWebJs
ExpressWebJs is a Node FrameWork with expressive and organised syntax that runs on all major operating systems. It provides the starting point for creating your node project, allowing you to focus more on developing your amazing solution. It takes the pain out of development by easing common tasks (Environment Setup, Code Structure, Robust routi…
Stars: ✭ 58 (+190%)
Mutual labels:  api-server
webapi
WAI based library for web api
Stars: ✭ 27 (+35%)
Mutual labels:  api-server
microAuth
A fast, documented, and tested python3 API boilerplate
Stars: ✭ 24 (+20%)
Mutual labels:  api-server
greldal
A micro-framework for bidirectional mapping between relational datastores and GraphQL APIs (powered by Node.js)
Stars: ✭ 58 (+190%)
Mutual labels:  api-server
nova
Web framework for Erlang.
Stars: ✭ 175 (+775%)
Mutual labels:  api-server
node-server
(@nestjs refactoring)⚡️My personal website's api server, a RESTful application that powered by @eggjs
Stars: ✭ 17 (-15%)
Mutual labels:  api-server
bitbot
Bitbot: Rack based Slack bot with a responder DSL and support for Wit.ai natural language processing.
Stars: ✭ 13 (-35%)
Mutual labels:  rack

Rack::Idempotency

Gem Version Build Status Code Climate Test Coverage

Rack middleware ensuring at most once requests for mutating endpoints.

Inspired by this stripe blog post.

Installation

Add this line to your application's Gemfile:

gem "rack-idempotency"

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-idempotency

Server Usage

Rack::Idempotency is implemented as a piece of Rack middleware and can be used with any Rack-based application. If your application includes a rackup (.ru) file or uses Rack::Builder to construct the application pipeline, simply require and use as follows:

require "rack/idempotency"

use Rack::Idempotency, store: Rack::Idempotency::MemoryStore.new

run app

The store argument should be any object that responds to both read(id) and write(id, value). Rack::Idempotency::MemoryStore is good for testing, but should not be used in production.

Using with Rails

config.before_initialize do
  config.middleware.use Rack::Idempotency, store: Rails.cache
end

Client Usage

Rack::Idempotency works with any client that sets an Idempotency-Key header. If the request succeeds, any subsequent request with the same key will return a cached response.

Considerations

Rack::Idempotency should handle the following cases:

  • The initial connection to the server fails.
  • The request fails halfway through, leaving data in limbo.
  • The request succeeds, but the connection to the client is lost.

The second case is much more dependent on implementation. Rack::Idempotency assumes that the request is in a transaction and can be safely retried if it wasn't successful.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/guitsaru/rack-idempotency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].