saseo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/saseo_consumer +1 -0
- data/exe/saseo_publisher +1 -0
- data/lib/saseo/persistence/consumer.rb +13 -1
- data/lib/saseo/persistence/persistor.rb +13 -5
- data/lib/saseo/publishing/publisher.rb +2 -2
- data/lib/saseo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8584935e166a1c98a8850d9247901ed8d5d4d68e
|
4
|
+
data.tar.gz: a7f7978c8849140dc105cbe2c67cec42494a179e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 052d69970c0f6eef0023976c481d9d1372bc075dd343cbd3ad6f5c553518f512331188d5b8a3fc3193ef632e7d7dcf3bd31edbceae3aaf470157279cabd37ce5
|
7
|
+
data.tar.gz: 435bc66217e046e9d3ccdb884f83b55b09b6163058995b446ff72f209a4128da730eb6dd03e679cb11fb6d90dc1aee9bf1078ceac98401531ce22909e2c8205c
|
data/exe/saseo_consumer
CHANGED
data/exe/saseo_publisher
CHANGED
@@ -12,12 +12,24 @@ module Saseo
|
|
12
12
|
|
13
13
|
def consume(message)
|
14
14
|
begin
|
15
|
+
logger.debug { "recieved version: #{message.id}" }
|
15
16
|
Saseo::Persistence::Persistor.persist! message
|
16
17
|
|
17
18
|
acknowledge message
|
18
19
|
rescue => e
|
20
|
+
reject message, true
|
21
|
+
error_data = {
|
22
|
+
saseo_consumer_error: true,
|
23
|
+
message: e.message,
|
24
|
+
error_class: e.class.name,
|
25
|
+
trace: e.backtrace
|
26
|
+
}
|
27
|
+
|
28
|
+
logger.error { "rejected version: #{error_data}" }
|
29
|
+
|
19
30
|
# be sure to create a queue that monitors for saseo_consumer_error: true
|
20
|
-
Philotic::Message.publish(
|
31
|
+
Philotic::Message.publish(error_data)
|
32
|
+
raise e
|
21
33
|
end
|
22
34
|
end
|
23
35
|
end
|
@@ -6,6 +6,8 @@ module Saseo
|
|
6
6
|
module Persistor
|
7
7
|
extend self
|
8
8
|
|
9
|
+
attr_writer :logger
|
10
|
+
|
9
11
|
def version_attributes
|
10
12
|
%i[
|
11
13
|
id
|
@@ -19,18 +21,24 @@ module Saseo
|
|
19
21
|
]
|
20
22
|
end
|
21
23
|
|
24
|
+
def logger
|
25
|
+
@logger ||= Logger.new(STDOUT)
|
26
|
+
end
|
27
|
+
|
22
28
|
def persist!(message)
|
23
|
-
|
29
|
+
logger.debug { "recieved source version for persistence: #{message.id}" }
|
30
|
+
version = Saseo::Models::Version.new
|
24
31
|
|
25
32
|
version_attributes.each do |attr|
|
26
|
-
|
33
|
+
version.send("#{attr}=", message.send(attr))
|
27
34
|
end
|
28
35
|
|
29
36
|
# ActiveRecord 3 doesn't handle jsonb columns properly
|
30
|
-
|
31
|
-
|
37
|
+
version.old_data = message.old_data && Oj.dump(message.old_data)
|
38
|
+
version.new_data = message.new_data && Oj.dump(message.new_data)
|
32
39
|
|
33
|
-
|
40
|
+
version.save!
|
41
|
+
logger.debug { "saved version: #{message.id}" }
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
@@ -36,15 +36,15 @@ module Saseo
|
|
36
36
|
|
37
37
|
def run(channels: :all, loop: true, timeout: nil)
|
38
38
|
self.channels = channels
|
39
|
-
logger.info "listening on #{self.channels}..."
|
40
|
-
|
41
39
|
listen channels: self.channels, loop: loop, timeout: timeout do |channel, pid, payload|
|
42
40
|
uuid = payload
|
41
|
+
logger.debug { "received NOTIFY for source version: #{uuid}"}
|
43
42
|
Saseo::Models::Source::Base.transaction do
|
44
43
|
|
45
44
|
record = Saseo::Models::Source::Version.find(uuid)
|
46
45
|
Saseo::Publishing::DataChangeMessage.publish(record)
|
47
46
|
record.delete
|
47
|
+
logger.debug { "deleted source version: #{uuid}"}
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/saseo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saseo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Keyes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|