https://github.com/alphasights/sneakers_toolbox
Various helpers and convenience classes/modules/methods to help simplify working with Sneakers and get around common issues
https://github.com/alphasights/sneakers_toolbox
Last synced: 5 months ago
JSON representation
Various helpers and convenience classes/modules/methods to help simplify working with Sneakers and get around common issues
- Host: GitHub
- URL: https://github.com/alphasights/sneakers_toolbox
- Owner: alphasights
- License: mit
- Created: 2018-10-24T07:05:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-05T14:50:22.000Z (almost 4 years ago)
- Last Synced: 2024-12-30T10:44:23.753Z (over 1 year ago)
- Language: Ruby
- Size: 17.6 KB
- Stars: 1
- Watchers: 29
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SneakersToolbox
Various helpers and convenience classes/modules/methods to help simplify working with Sneakers and get around common issues
## Components
### LostDbConnectionHandler
Sometimes ActiveRecord can lose connection and not be aware of it (thus not re-connecting). It can happen for example when connecting through a QuotaGuard tunnel. This results in `ActiveRecord::StatementInvalid` exception being thrown. `SneakersToolbox::LostDbConnectionHandler` uses this fact to clear all connections, forcing them to be reestablished. You can use this functionality with:
```ruby
def work(*args)
payload, *extra = args
payload = JSON.parse(payload) unless payload.class == Hash
SneakersToolbox::LostDbConnectionHandler.with_connection { process_message(payload, *extra) }
rescue => error
Honeybadger.notify(error, context: payload)
raise error
end
```