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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7e02fae40b268652d0187bfff203ea94993204069992b05d71808a3a820b28b
|
4
|
+
data.tar.gz: c78fdc01af8ca386f23babbcc409535e4c983238af4a13e3541d32f8b30b7f96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 |
|
90
|
+
records.group_by(&:split_key).each do |split_key, records2|
|
91
91
|
begin
|
92
|
-
|
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
|
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 #{
|
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
|
120
|
-
|
121
|
-
|
122
|
-
|
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
|
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.
|
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
|