GA
ActiveRecordEventPublisher
Publish all create, update, and destroy events to an SQS queue.
Installation
Add this line to your application's Gemfile:
gem 'active_record_event_publisher', :git => 'https://github.com/gamut-code/active_record_event_publisher'Setup
Add this configuration initializer to your app
config/initializers/active_record_event_publisher.rb
ActiveRecordEventPublisher.configure do |config|
config.queue_url = 'http://example.com'
config.enabled = false # only enable in production environment
config.log = true # default is false
endRestart your app, and all events will be published to SQS.
Publish Format
The following attributes are published on each data change event:
action- One of the follow options,create,update, ordestroysubject_id- The primary key of the object affected by the changesubject_class- The class name of the object affected by the changesubject- All attributes of the object affected by the changechanges- Only the attributes affected by the change, including their before and after statecreated_at- The date, time and zone of when the event happened in ISO 8601 format.
{
"action": "(create|update|destroy)",
"subject_id": "(objectId)",
"subject_class": "(objectClass)",
"subject": {
"(objectAttribute1Key)": "(objectAttribute1Value)",
"(objectAttribute2Key)": "(objectAttribute2Value)",
},
"changes": {
"(changedAttribute1)": [
"(changedAttribute1Before)",
"(changedAttribute1After)"
],
"(changedAttribute2)": [
"(changedAttribute2Before)",
"(changedAttribute2After)"
]
},
"created_at": "(timestamp)"
}Bugs & Feature Requests
Please add an issue in Github if you discover a bug or have a feature request.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
License
The gem is available as open source under the terms of the MIT License.