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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13c887bdc257323e0273ef0b9dc529e01ba99bcc
4
- data.tar.gz: 21131a2fd553dab157facf48ba0e4e7cacb321aa
3
+ metadata.gz: 8584935e166a1c98a8850d9247901ed8d5d4d68e
4
+ data.tar.gz: a7f7978c8849140dc105cbe2c67cec42494a179e
5
5
  SHA512:
6
- metadata.gz: 0eb41500a2fc709e0aab838e6f724d3922359e91c821f68735ab644d05451f7853ee14937ba328536bf4d5192569a4597cf3cee5d6087321da78774451489605
7
- data.tar.gz: 352a0efffeeca3687497461015391efb93e4c1aaba33d781dd68970bdc35182603c2c234b1a0b998fdb8ecf2fbe10f55e8f99524e429b44a4c558229298929dd
6
+ metadata.gz: 052d69970c0f6eef0023976c481d9d1372bc075dd343cbd3ad6f5c553518f512331188d5b8a3fc3193ef632e7d7dcf3bd31edbceae3aaf470157279cabd37ce5
7
+ data.tar.gz: 435bc66217e046e9d3ccdb884f83b55b09b6163058995b446ff72f209a4128da730eb6dd03e679cb11fb6d90dc1aee9bf1078ceac98401531ce22909e2c8205c
data/exe/saseo_consumer CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $stdout.sync = true
2
3
  $:.unshift File.expand_path('../../lib', __FILE__)
3
4
 
4
5
  require 'saseo/persistence/consumer'
data/exe/saseo_publisher CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $stdout.sync = true
2
3
  $:.unshift File.expand_path('../../lib', __FILE__)
3
4
 
4
5
  require 'saseo/publishing/publisher'
@@ -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({saseo_consumer_error: true, message: e.message, error_class: e.class.name, trace: e.backtrace})
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
- version_record = Saseo::Models::Version.new
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
- version_record.send("#{attr}=", message.send(attr))
33
+ version.send("#{attr}=", message.send(attr))
27
34
  end
28
35
 
29
36
  # ActiveRecord 3 doesn't handle jsonb columns properly
30
- version_record.old_data = message.old_data && Oj.dump(message.old_data)
31
- version_record.new_data = message.new_data && Oj.dump(message.new_data)
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
- version_record.save!
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
@@ -1,3 +1,3 @@
1
1
  module Saseo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-02 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print