sidekiq-haron 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sidekiq/haron/exception_logger.rb +4 -3
- data/lib/sidekiq/haron/storage.rb +15 -1
- data/lib/sidekiq/haron/version.rb +1 -1
- data/lib/sidekiq/haron.rb +10 -9
- data/sidekiq-haron.gemspec +4 -4
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a903c22b5c1696535db961a28828fa539cebb6695154b4082fb10fd3041f2c53
|
4
|
+
data.tar.gz: 9e405c2c5a4e5266d2cd735b13f6dc10c918d35bebda275e690e21b79b491e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3259615f6d5ad26bd53dd1a1f9a934d2f4b1c0ba4099be5062b58dbd103731fff12f0951cac8bc64564d1016b33d721b096980e8419c7f02ab65ab84383dd4a
|
7
|
+
data.tar.gz: 5a86580af78520badd3c3a75a9ac4ebb464a7b408b49f497188f82841aa54a41a5a0ce4e1d33b17776954de6e2fdd7d2b38d056d7836c819c1bf04ecf7d5a7c5
|
@@ -2,10 +2,11 @@ module Sidekiq
|
|
2
2
|
module Haron
|
3
3
|
class ExceptionLogger
|
4
4
|
|
5
|
-
def call(ex,
|
6
|
-
jid =
|
5
|
+
def call(ex, ctx_hash, config)
|
6
|
+
jid = ctx_hash.present? && ctx_hash[:job]['jid']
|
7
|
+
|
7
8
|
Sidekiq::Haron.transmitter.load(jid) if jid.present?
|
8
|
-
Sidekiq::Haron.transmitter.tagged{
|
9
|
+
Sidekiq::Haron.transmitter.tagged{ Sidekiq.logger.warn ex.message }
|
9
10
|
end
|
10
11
|
|
11
12
|
end
|
@@ -9,7 +9,21 @@ module Sidekiq
|
|
9
9
|
def store_for_id(id, data, redis_pool=nil)
|
10
10
|
redis_connection(redis_pool) do |conn|
|
11
11
|
conn.multi do |pipeline|
|
12
|
-
|
12
|
+
# При попытке записи хэша с полями nil, true, false
|
13
|
+
# валится задание с исключением "Unsupported command argument type: NilClass/TrueClass/FalseClass (TypeError)"
|
14
|
+
# Пример из консоли Rails (такое же поведение в "бою", данные взяты из реальных кейсов)
|
15
|
+
# d = [ :request_id, "9c30943e299135b1fe826d7be6195e78", :parent_request_id, "9c30943e",:user_id, nil ]
|
16
|
+
# Sidekiq.redis { |c| c.call('hmset', "kkk", d) }
|
17
|
+
# ~/.rvm/gems/ruby-3.3.5/gems/irb-1.14.1/lib/irb.rb:1260:in `full_message': Unsupported command argument type: NilClass (TypeError)
|
18
|
+
# raise TypeError, "Unsupported command argument type: #{element.class}"
|
19
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
20
|
+
# Потому введена интерпретация значений:
|
21
|
+
# nil - ''
|
22
|
+
# true - 1
|
23
|
+
# false - 0
|
24
|
+
values = data.to_a.flatten(1).map{ |each| each.nil? ? '' : each }.map{ |each| each == true ? 1 : (each == false ? 0 : each) }
|
25
|
+
# уход от deprecated-предупреждений внутри sidekiq - нативный вызов hmset для клиента redis
|
26
|
+
pipeline.call('hmset', key(id), *(values))
|
13
27
|
pipeline.expire key(id), DEFAULT_EXPIRY
|
14
28
|
end[0]
|
15
29
|
end
|
data/lib/sidekiq/haron.rb
CHANGED
@@ -12,16 +12,16 @@ module Sidekiq
|
|
12
12
|
module Haron
|
13
13
|
|
14
14
|
def self.transmitter
|
15
|
-
|
15
|
+
@transmitter
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.transmitter= v
|
19
|
-
|
19
|
+
@transmitter = v
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.install transmitter_class
|
22
|
+
def self.install transmitter_class, with_tagged_logging: true
|
23
23
|
Sidekiq::Haron.transmitter = transmitter_class.new
|
24
|
-
set_loggers
|
24
|
+
set_loggers with_tagged_logging
|
25
25
|
Sidekiq.configure_server do |c|
|
26
26
|
configure_client_middleware(c)
|
27
27
|
configure_server_middleware(c)
|
@@ -31,13 +31,14 @@ module Sidekiq
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.set_loggers
|
34
|
+
def self.set_loggers with_tagged_logging
|
35
35
|
Sidekiq.configure_server do |config|
|
36
|
-
config.
|
36
|
+
config.logger.formatter = Sidekiq::Haron::Formatter.new
|
37
|
+
config.logger = ActiveSupport::TaggedLogging.new(Sidekiq.logger) if with_tagged_logging
|
38
|
+
|
39
|
+
config[:job_logger] = Sidekiq::Haron::JobLogger
|
40
|
+
config.error_handlers << Sidekiq::Haron::ExceptionLogger.new
|
37
41
|
end
|
38
|
-
Sidekiq[:job_logger] = Sidekiq::Haron::JobLogger
|
39
|
-
Sidekiq[:error_handlers] << Sidekiq::Haron::ExceptionLogger.new
|
40
|
-
Sidekiq.logger = ActiveSupport::TaggedLogging.new(Sidekiq.logger)
|
41
42
|
end
|
42
43
|
|
43
44
|
def self.configure_client_middleware(sidekiq_config)
|
data/sidekiq-haron.gemspec
CHANGED
@@ -23,10 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_dependency "sidekiq", "~>
|
27
|
-
spec.add_dependency "rails"
|
28
|
-
spec.add_development_dependency "bundler", "~>
|
29
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_dependency "sidekiq", "~> 7.3.0"
|
27
|
+
spec.add_dependency "rails", '~> 7.0'
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.5.0"
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
31
|
spec.add_development_dependency "awesome_print"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-haron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serg F
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 7.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '7.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '7.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.5.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|