eventq_base 1.8.0 → 1.9.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: 4a2ac127f57aef44a90cfea420a1087cd1fcc378
4
- data.tar.gz: 990a985365ea09620740ff7a649ee337d66bf308
3
+ metadata.gz: b9bc3112466190971bbe97e300c6f4ef72970648
4
+ data.tar.gz: 85a09ef777f2e608c4a2718f480f12c8354736a2
5
5
  SHA512:
6
- metadata.gz: e5de8a9e071f90e0fc94bdb092ff6e66940ca6002749697a732c54bd5963d01f5ceb163fe127cf7b0b238006e4f164171803daef72e4a758513330932bc60bec
7
- data.tar.gz: 1188228dd7b85272b80e68d80207aa57e93168df7b7b9b796036d9b988e4b7cf2c9d2f3f46ec8be47f204611a583d0e0399470041a2e32ad12e40cfb6005a548
6
+ metadata.gz: c45c1567f96f19ee6bad46b13952ba15310e8d1844d4f6ef8f05c3257ce04237e00207bb6416088c280a6c910d6396e558d4a87eac4413caa16427e90ad2c6e7
7
+ data.tar.gz: 71fd49d6da0e584d89fe579887af57456c85499a5b8f3308cc6521eaaa13e11dd6656c049dd530a82e889ca608b741990f3238f98b297008cab843790369944d
@@ -19,38 +19,32 @@ module EventQ
19
19
  @lifespan
20
20
  end
21
21
 
22
- def self.process(nonce, &block)
23
-
24
- if @server_url != nil
25
-
26
- process_with_nonce(nonce, block)
27
-
28
- else
29
-
30
- process_without_nonce(block)
22
+ def self.is_allowed?(nonce)
23
+ if @server_url == nil
24
+ return true
25
+ end
31
26
 
27
+ lock = Redlock::Client.new([ @server_url ]).lock(nonce, @timeout)
28
+ if lock == false
29
+ EventQ.log(:info, "Message has already been processed: #{nonce}")
30
+ return false
32
31
  end
33
32
 
34
33
  return true
35
-
36
34
  end
37
35
 
38
- def self.process_with_nonce(nonce, block)
39
- @server = Redlock::Client.new([ @server_url ])
40
- @redis = Redis.new(url: @server_url)
41
-
42
- lock = @server.lock(nonce, @timeout)
43
- if lock == false
44
- raise NonceError.new("Message has already been processed: #{nonce}")
36
+ def self.complete(nonce)
37
+ if @server_url != nil
38
+ Redis.new(url: @server_url).expire(nonce, @lifespan)
45
39
  end
46
-
47
- block.call
48
-
49
- @redis.expire(nonce, @lifespan)
40
+ return true
50
41
  end
51
42
 
52
- def self.process_without_nonce(block)
53
- block.call
43
+ def self.failed(nonce)
44
+ if @server_url != nil
45
+ Redis.new(url: @server_url).del(nonce)
46
+ end
47
+ return true
54
48
  end
55
49
 
56
50
  def self.reset
@@ -1,3 +1,3 @@
1
1
  module EventqBase
2
- VERSION = "1.8.0"
2
+ VERSION = "1.9.0"
3
3
  end
data/lib/eventq_base.rb CHANGED
@@ -18,6 +18,5 @@ require_relative 'eventq_base/eventq_client_contract'
18
18
  require_relative 'eventq_base/configuration'
19
19
  require_relative 'eventq_base/serialization_providers'
20
20
  require_relative 'eventq_base/worker_id'
21
- require_relative 'eventq_base/nonce_error'
22
21
  require_relative 'eventq_base/nonce_manager'
23
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq_base
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
@@ -154,7 +154,6 @@ files:
154
154
  - lib/eventq_base/eventq_logger.rb
155
155
  - lib/eventq_base/exchange.rb
156
156
  - lib/eventq_base/message_args.rb
157
- - lib/eventq_base/nonce_error.rb
158
157
  - lib/eventq_base/nonce_manager.rb
159
158
  - lib/eventq_base/queue.rb
160
159
  - lib/eventq_base/queue_message.rb
@@ -1,7 +0,0 @@
1
- module EventQ
2
- class NonceError < StandardError
3
- def initialize(message = 'Message has already been processed.')
4
- super(message)
5
- end
6
- end
7
- end