mirror of
https://github.com/ditkrg/idempotent-request.git
synced 2026-01-22 22:06:44 +00:00
update changelog, add readme regardless usage of ActiveSupport::Notifications
This commit is contained in:
parent
8f354b9883
commit
29f3709846
@ -1,5 +1,10 @@
|
|||||||
# Idempotent Request Changelog #
|
# Idempotent Request Changelog #
|
||||||
|
|
||||||
|
## v0.1.5 ##
|
||||||
|
|
||||||
|
* use ActiveSupport::Notifications to instrument events
|
||||||
|
* fix an issue when getting an exception inside application would not delete lock, so client could receive 429 after 500
|
||||||
|
|
||||||
## v0.1.4 ##
|
## v0.1.4 ##
|
||||||
|
|
||||||
* Fix an issue, when http response from backend != 200..226 caused lock to be taken
|
* Fix an issue, when http response from backend != 200..226 caused lock to be taken
|
||||||
|
|||||||
17
README.md
17
README.md
@ -84,6 +84,23 @@ module IdempotentRequest
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Use ActiveSupport::Notifications to read events
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
# config/initializers/idempotent_request.rb
|
||||||
|
ActiveSupport::Notifications.subscribe('idempotent.request') do |name, start, finish, request_id, payload|
|
||||||
|
notification = payload[:request].env['idempotent.request']
|
||||||
|
if notification['read']
|
||||||
|
Rails.logger.info "IdempotentRequest: Hit cached response from key #{notification['key']}, response: #{notification['read']}"
|
||||||
|
elsif notification['write']
|
||||||
|
Rails.logger.info "IdempotentRequest: Write: key #{notification['key']}, status: #{notification['write'][0]}, headers: #{notification['write'][1]}, unlocked? #{notification['unlocked']}"
|
||||||
|
elsif notification['concurrent_request_response']
|
||||||
|
Rails.logger.warn "IdempotentRequest: Concurrent request detected with key #{notification['key']}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## Custom options
|
## Custom options
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user