aws-broker 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -12
- metadata +2 -3
- data/lib/shoryuken/subscriber.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b938dd1e263fd48b2cc64c96655f5aff24f78b6
|
4
|
+
data.tar.gz: 52ebfad9aea471cb056d45b937df66f4935aa588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06483e64b65a4d5c50b945ac002dc26923bc181e3f4ac7135738cbd17bfcd2dfa80ec11736973571898e004c8d60bd5e3052c8c2491741fc241e2759a36ea5a0
|
7
|
+
data.tar.gz: 1473da73a1c476be4fe019da90ad20be2fb31cd29787950e1b61b9d94389a4066389a68cf488abc3aa81b68dd77945f431edfcf87265668fba8dbde9dd78ccd7
|
data/README.md
CHANGED
@@ -40,27 +40,23 @@ accompanying RSpec matcher is provided if the project is Rails. This simplifies
|
|
40
40
|
the process of publishing events for ActiveRecord create, update, and destroy
|
41
41
|
callbacks.
|
42
42
|
|
43
|
-
|
43
|
+
#### Publishing
|
44
44
|
|
45
45
|
# app/models/user.rb
|
46
46
|
class User < ActiveRecord::Base
|
47
47
|
publish_event :create, :update, :destroy
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
The above is essentially shorthand for
|
51
51
|
|
52
|
-
# app/
|
53
|
-
class
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
def update; ... end
|
59
|
-
|
60
|
-
def destroy; ... end
|
52
|
+
# app/models/user.rb
|
53
|
+
class User < ActiveRecord::Base
|
54
|
+
after_commit on: :create do
|
55
|
+
Broker.publish(:user, event: :create, id: id)
|
56
|
+
end
|
61
57
|
end
|
62
58
|
|
63
|
-
|
59
|
+
#### Testing
|
64
60
|
|
65
61
|
# spec/rails_helper.rb
|
66
62
|
require 'aws/broker/matchers'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eng @ Thanx
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-sns
|
@@ -54,7 +54,6 @@ files:
|
|
54
54
|
- lib/aws/broker/publishing.rb
|
55
55
|
- lib/aws/broker/railtie.rb
|
56
56
|
- lib/aws/broker/subscriber.rb
|
57
|
-
- lib/shoryuken/subscriber.rb
|
58
57
|
homepage: https://github.com/thanx/aws-broker
|
59
58
|
licenses:
|
60
59
|
- MIT
|
data/lib/shoryuken/subscriber.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Shoryuken
|
2
|
-
class Subscriber
|
3
|
-
include Shoryuken::Worker
|
4
|
-
|
5
|
-
class << self
|
6
|
-
attr_reader :resource_class
|
7
|
-
|
8
|
-
def queue=(queue)
|
9
|
-
shoryuken_options(
|
10
|
-
queue: queue,
|
11
|
-
auto_delete: true,
|
12
|
-
body_parser: :json
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
def resource_class=(klass)
|
17
|
-
@resource_class = klass
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def perform(_, body)
|
22
|
-
@body = body
|
23
|
-
send(event)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def resource
|
29
|
-
@resource ||= self.class.resource_class.constantize.find(message[:id])
|
30
|
-
end
|
31
|
-
|
32
|
-
def event
|
33
|
-
message[:event]
|
34
|
-
end
|
35
|
-
|
36
|
-
def message
|
37
|
-
@message ||= JSON.parse(@body['Message']).symbolize_keys
|
38
|
-
rescue JSON::ParserError
|
39
|
-
{}
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|