ruby_event_store-outbox 0.0.9 → 0.0.10

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
  SHA256:
3
- metadata.gz: da07b2263a96dbbfaad959ab5dd5636d5bb3398d810894080ab6e3f80750c29f
4
- data.tar.gz: 53cd5a2de183f9c821eacf6c05689f42e1fdc39120aac25aa450f90601bbd964
3
+ metadata.gz: d7e02fae40b268652d0187bfff203ea94993204069992b05d71808a3a820b28b
4
+ data.tar.gz: c78fdc01af8ca386f23babbcc409535e4c983238af4a13e3541d32f8b30b7f96
5
5
  SHA512:
6
- metadata.gz: d6e7cb309a64e4743ae5e6d182987c7b1d35378b0a371ce784c2f0695de026903a92d58106e98fdbab73687bf0c35f89912a614982f8347e5b4d0f0ab0daabf4
7
- data.tar.gz: 1d7fe76b631564b4205dab9f928da9487e6db08cf93cee9b52a975b7cad65dddd07de97babd586851855c262f1428f902a3612185b9bc0fc7f3a4fa848c0024c
6
+ metadata.gz: cca7886a64c64912770e4415ec65523309c6af0ef5edbc0c3d5a55fd2e7937be36517104d0539a1436e006af5623f82d0f7be09e79f2b78604fd257c85d8c0ed
7
+ data.tar.gz: d8435157be3745483024b2ddbc867502a0a340a10846485b35ac204eba845b5e05da924f24771b9b8e697b911c9c3eb605c5d7129c4fe8c9e0d66ca04138e6eb
@@ -87,11 +87,12 @@ module RubyEventStore
87
87
 
88
88
  now = @clock.now.utc
89
89
  failed_record_ids = []
90
- records.each do |record|
90
+ records.group_by(&:split_key).each do |split_key, records2|
91
91
  begin
92
- handle_one_record(now, record)
92
+ failed = handle_group_of_records(now, split_key, records2)
93
+ failed_record_ids.concat(failed.map(&:id))
93
94
  rescue => e
94
- failed_record_ids << record.id
95
+ failed_record_ids.concat(records2.map(&:id))
95
96
  e.full_message.split($/).each {|line| logger.error(line) }
96
97
  end
97
98
  end
@@ -100,7 +101,7 @@ module RubyEventStore
100
101
  Record.where(id: updated_record_ids).update_all(enqueued_at: now)
101
102
  metrics.write_point_queue(status: "ok", enqueued: updated_record_ids.size, failed: failed_record_ids.size)
102
103
 
103
- logger.info "Sent #{records.size} messages from outbox table"
104
+ logger.info "Sent #{updated_record_ids.size} messages from outbox table"
104
105
  true
105
106
  end
106
107
  rescue ActiveRecord::Deadlocked
@@ -116,11 +117,21 @@ module RubyEventStore
116
117
  private
117
118
  attr_reader :split_keys, :logger, :message_format, :batch_size, :metrics
118
119
 
119
- def handle_one_record(now, record)
120
- hash_payload = JSON.parse(record.payload)
121
- @redis.lpush("queue:#{hash_payload.fetch("queue")}", JSON.generate(JSON.parse(record.payload).merge({
122
- "enqueued_at" => now.to_f,
123
- })))
120
+ def handle_group_of_records(now, split_key, records)
121
+ failed = []
122
+ elements = []
123
+ records.each do |record|
124
+ begin
125
+ elements << JSON.generate(JSON.parse(record.payload).merge({
126
+ "enqueued_at" => now.to_f,
127
+ }))
128
+ rescue => e
129
+ failed << record
130
+ e.full_message.split($/).each {|line| logger.error(line) }
131
+ end
132
+ end
133
+ @redis.lpush("queue:#{split_key}", elements)
134
+ failed
124
135
  end
125
136
 
126
137
  def prepare_traps
@@ -1,13 +1,12 @@
1
- require "ruby_event_store/outbox/metrics/null"
2
- require "ruby_event_store/outbox/metrics/influx"
3
-
4
1
  module RubyEventStore
5
2
  module Outbox
6
3
  module Metrics
7
4
  def self.from_url(metrics_url)
8
5
  if metrics_url.nil?
6
+ require "ruby_event_store/outbox/metrics/null"
9
7
  Null.new
10
8
  else
9
+ require "ruby_event_store/outbox/metrics/influx"
11
10
  Influx.new(metrics_url)
12
11
  end
13
12
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module Outbox
5
- VERSION = "0.0.9"
5
+ VERSION = "0.0.10"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-outbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
- - !ruby/object:Gem::Dependency
42
- name: influxdb
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.8.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.8.0
55
41
  description:
56
42
  email:
57
43
  - dev@arkency.com