cyclone_lariat 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5458f171a6a306641b03d57341f62228b73a49c2aa222c49e764dd2194c1ab61
4
- data.tar.gz: 3fd96a4dcd07b7a52203161b75023b480312b0a6a4bf3eb76ecbaecb8122d8a9
3
+ metadata.gz: 0cebf79d1deb7a107446827a619897bf59364b89e8745fd767ed001bea3d6272
4
+ data.tar.gz: 6ff840519d31a46ab2f2ae6615176489041154213093052d5f924495dd537a20
5
5
  SHA512:
6
- metadata.gz: 22b7f9b1c2e438368a329d118f6fcfc0b659d12d42590cea25db4961ed17ac0f36904f67a0ea18d7c6498dae5ab8b66033155bec6a883a9c0fceb1024c8b8a1a
7
- data.tar.gz: ee83d106d2cf8fcee7831aece4b52ebf1083f6ec1ceb37adaea106fda27bd747907301b5baaa6efd6c420c970a6a45495a976508bf0683be71fb17b09a6634d4
6
+ metadata.gz: 45eab91fdef2c3c97d6638bf2ec0bf5d83dbaa54b18037a8245d25f2142b4582d60cd771c758f6d9300b2ed51977ce430864606f9155b2a235592470e92db539
7
+ data.tar.gz: 2f58eef796c7e0c52b6f3b8e4341466f7c8baf77ca3a6ff482e4435bd4aad73c04e1a667f39a11d820e774421c58b0519ce8401bdd1984ad872178a85d92a034
data/CHANGELOG.md CHANGED
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [0.3.0] - 2021-06-11
7
+ ## [0.3.2] - 2021-06-11
8
+ Changed
9
+ - Bugfix
10
+
11
+ ## [0.3.1] - 2021-06-11
8
12
  Changed
9
13
  - Command
10
14
  - SqsClient
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cyclone_lariat (0.3.1)
4
+ cyclone_lariat (0.3.2)
5
5
  aws-sdk-sns
6
6
  aws-sdk-sqs
7
7
  luna_park (~> 0.11)
data/README.md CHANGED
@@ -159,7 +159,6 @@ class Receiver
159
159
  queue: 'your_sqs_queue_name'
160
160
 
161
161
  server_middleware do |chain|
162
-
163
162
  # Options dataset, errors_notifier and message_notifier is optionals.
164
163
  # If you dont define notifiers - middleware does not notify
165
164
  # If you dont define dataset - middleware does store events in db
@@ -9,13 +9,8 @@ module CycloneLariat
9
9
  attr :uuid, String, :new
10
10
  attr :publisher, String, :new
11
11
  attr :type, String, :new
12
- attr :client_error
13
- attr :version
14
- attr :data
15
-
16
- attr_reader :sent_at,
17
- :processed_at,
18
- :received_at
12
+ attrs :client_error, :version, :data,
13
+ :sent_at, :processed_at, :received_at
19
14
 
20
15
  def kind
21
16
  raise LunaPark::Errors::AbstractMethod
@@ -37,6 +32,10 @@ module CycloneLariat
37
32
  @processed_at = wrap_time(value)
38
33
  end
39
34
 
35
+ def processed?
36
+ !@processed_at.nil?
37
+ end
38
+
40
39
  def client_error_message=(txt)
41
40
  return unless txt
42
41
 
@@ -77,7 +76,7 @@ module CycloneLariat
77
76
  when String then Time.parse(value)
78
77
  when Time then value
79
78
  when NilClass then nil
80
- else raise Argumentevent.rbError, "Unknown type `#{value.class}`"
79
+ else raise ArgumentError, "Unknown type `#{value.class}`"
81
80
  end
82
81
  end
83
82
  end
@@ -37,6 +37,8 @@ module CycloneLariat
37
37
 
38
38
  def find(uuid:)
39
39
  raw = dataset.where(uuid: uuid).first
40
+ return nil unless raw
41
+
40
42
  raw[:data] = JSON.parse(raw[:data], symbolize_names: true)
41
43
  if raw[:client_error_details]
42
44
  raw[:client_error_details] = JSON.parse(raw[:client_error_details], symbolize_names: true)
@@ -20,8 +20,8 @@ module CycloneLariat
20
20
  catch_standard_error(queue, msg) do
21
21
  event = Event.wrap(msg)
22
22
 
23
- catch_business_error(event) do
24
- store_in_dataset(event, &block)
23
+ store_in_dataset(event) do
24
+ catch_business_error(event, &block)
25
25
  end
26
26
  end
27
27
  end
@@ -36,9 +36,11 @@ module CycloneLariat
36
36
 
37
37
  def store_in_dataset(event)
38
38
  return yield if events_repo.nil?
39
- return true if events_repo.exists?(uuid: event.uuid)
40
39
 
41
- events_repo.create(event)
40
+ existed = events_repo.find(uuid: event.uuid)
41
+ return true if existed&.processed?
42
+
43
+ events_repo.create(event) unless existed
42
44
  yield
43
45
  events_repo.processed! uuid: event.uuid, error: event.client_error
44
46
  end
@@ -52,7 +54,7 @@ module CycloneLariat
52
54
 
53
55
  def catch_standard_error(queue, msg)
54
56
  yield
55
- rescue StandardError => e
57
+ rescue Exception => e
56
58
  errors_notifier&.error(e, queue: queue, message: msg)
57
59
  raise e
58
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CycloneLariat
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclone_lariat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kudrin