alephant-sequencer 1.0.0 → 1.1.0

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: 7466abcf04d261c43c5530f34afd0175c147a632
4
- data.tar.gz: b4d75acc04a87e90a3ea5b4e38710ae71b54a18b
3
+ metadata.gz: 86b1297e01bdbd2d4c4f81a602b34e895b5ada82
4
+ data.tar.gz: e492fe5944c17e92b1afbc7ff0f8270558abe51d
5
5
  SHA512:
6
- metadata.gz: bdac309998678c0f708e1916637b695a668a2640e7d02da705b12b99e8c8a25fd6817bc5e359d7da6ba0b63455f25ef6217db73ffd16d2ac085cb78921810f26
7
- data.tar.gz: dc6ea117ba80d4eefb51278b632bc331248f68f482e679321bea31ef2983a6981899c7b4dbfcbe65572ac68ce1313f1001e879dfcf2a1da44703fb1df66c2ba7
6
+ metadata.gz: 83507711dee28f0b1a8d0abb4a2b5f06927caf541c641d18d4d566d0087320cf10f354e82672de1831c238735a396fe88b8edeae66843a8554de73278877cf6a
7
+ data.tar.gz: 88468c9d3df88230e5db48fe3f722e89c0bf18a92756555082f4f8179b6181d3a6ec110f4b9063f2051e8eae3ed32922f05d0b9f9d36f53f108896cd9a65c154
@@ -8,8 +8,7 @@ require "alephant/support/dynamodb/table"
8
8
  module Alephant
9
9
  module Sequencer
10
10
  class SequenceTable < ::Alephant::Support::DynamoDB::Table
11
- include ::Alephant::Logger
12
-
11
+ include Logger
13
12
  attr_reader :table_name, :client
14
13
 
15
14
  def initialize(table_name)
@@ -36,7 +35,7 @@ module Alephant
36
35
  data.length > 0 ? data[:item]["value"][:n].to_i : 0
37
36
  end
38
37
 
39
- def set_sequence_for(ident, value, last_seen_check = nil)
38
+ def update_sequence_id(ident, value, last_seen_check = nil)
40
39
  begin
41
40
 
42
41
  current_sequence = last_seen_check.nil? ? sequence_for(ident) : last_seen_check
@@ -67,9 +66,9 @@ module Alephant
67
66
  })
68
67
  end
69
68
 
70
- logger.info("SequenceTable#set_sequence_for: #{value} for #{ident} success!")
71
- rescue AWS::DynamoDB::Errors::ConditionalCheckFailedException => e
72
- logger.warn("SequenceTable#set_sequence_for: (Value to put: #{value}, existing: #{current_sequence}) #{ident} outdated!")
69
+ logger.info("SequenceTable#update_sequence_id: with new value #{value} for #{ident} success!")
70
+ rescue AWS::DynamoDB::Errors::ConditionalCheckFailedException
71
+ logger.warn("SequenceTable#update_sequence_id: (Value to put: #{value}, existing: #{current_sequence}) #{ident} outdated!")
73
72
  end
74
73
  end
75
74
 
@@ -1,5 +1,4 @@
1
1
  require 'jsonpath'
2
-
3
2
  require 'alephant/logger'
4
3
 
5
4
  module Alephant
@@ -15,6 +14,7 @@ module Alephant
15
14
  @exists = exists?
16
15
  @jsonpath = sequence_path
17
16
  @ident = id
17
+ logger.info("Sequencer#initialize: table: #{sequence_table}, jsonpath: #{sequence_path}, id: #{id}")
18
18
  end
19
19
 
20
20
  def sequential?(msg)
@@ -29,12 +29,12 @@ module Alephant
29
29
  last_seen_id = get_last_seen
30
30
  sequential = ((last_seen_id || 0) < Sequencer.sequence_id_from(msg, jsonpath))
31
31
 
32
- block.call(msg) if (sequential || keep_all)
32
+ block.call if (sequential || keep_all)
33
33
 
34
34
  if sequential
35
35
  set_last_seen(msg, last_seen_id)
36
36
  else
37
- logger.info("Sequencer#sequence nonsequential message for #{ident}")
37
+ logger.info("Sequencer#sequence nonsequential message for #{ident} (last_seen_id: #{last_seen_id})")
38
38
  end
39
39
  end
40
40
 
@@ -51,7 +51,7 @@ module Alephant
51
51
  def set_last_seen(msg, last_seen_check = nil)
52
52
  seen_id = Sequencer.sequence_id_from(msg, jsonpath)
53
53
 
54
- @sequence_table.set_sequence_for(
54
+ @sequence_table.update_sequence_id(
55
55
  ident, seen_id,
56
56
  (exists? ? last_seen_check : nil)
57
57
  )
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Sequencer
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -25,7 +25,7 @@ describe Alephant::Sequencer do
25
25
  table.stub(:create)
26
26
  table.stub(:sequence_exists)
27
27
  table.stub(:sequence_for)
28
- table.stub(:set_sequence_for)
28
+ table.stub(:update_sequence_id)
29
29
  table.stub(:truncate!)
30
30
  table
31
31
  end
@@ -58,10 +58,10 @@ describe Alephant::Sequencer do
58
58
 
59
59
  let(:a_proc) do
60
60
  a_block = double()
61
- a_block.should_receive(:called).with(message)
61
+ a_block.should_receive(:called)
62
62
 
63
- Proc.new do |msg|
64
- a_block.called(msg)
63
+ Proc.new do
64
+ a_block.called
65
65
  end
66
66
  end
67
67
 
@@ -69,7 +69,7 @@ describe Alephant::Sequencer do
69
69
  let(:stubbed_seen_high) { 3 }
70
70
  let(:stubbed_seen_low) { 1 }
71
71
 
72
- it "should call the passed block with msg" do
72
+ it "should call the passed block" do
73
73
  subject = Alephant::Sequencer::Sequencer.new(sequence_table, ident, jsonpath)
74
74
  subject.validate(message, &a_proc)
75
75
  end
@@ -203,12 +203,12 @@ describe Alephant::Sequencer do
203
203
  .and_return(last_seen)
204
204
  end
205
205
 
206
- it "calls set_sequence_for(ident, last_seen)" do
206
+ it "calls update_sequence_id(ident, last_seen)" do
207
207
  table = double()
208
208
  table.stub(:sequence_exists)
209
209
  table.stub(:create)
210
210
  table.stub(:sequence_for)
211
- table.should_receive(:set_sequence_for)
211
+ table.should_receive(:update_sequence_id)
212
212
  .with(ident, last_seen, nil)
213
213
 
214
214
  Alephant::Sequencer::Sequencer
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-sequencer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Kenny