sidekiq-haron 0.1.0 → 0.1.1

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: 22cd74baefe621ddce19baf896d194862eb7b5dc707fa0df8b3293856f4f2ce4
4
- data.tar.gz: 10f78860a68ccba3f377f3d40caa5c7ca22d1c39272d972d6f9c70b9510cceb1
3
+ metadata.gz: 8013e20dadb47994367e66c8bdbed92b6a0abf8d571d3bc6b7071d511dfe82b5
4
+ data.tar.gz: c6a9d958fb78125df046ad404093b3f41cde5fe5401a2dfc9a2cef79dc572779
5
5
  SHA512:
6
- metadata.gz: 11322d38ec911fe423c137f16dd5fe7c180950f302d921690a120020e6d6a4d1c9ad39915d158d3e234480d0a671e49d0be6f36ba61567741187b9805c2f7847
7
- data.tar.gz: 5f00881f12f9aea5aace610b43ce9e0c6b5d9dc189dcfa8cd713a339dc08daf7e2217b2afdd4a24950ddc3243e29c1d3a65f85c667669d93e8ddf55a4357c672
6
+ metadata.gz: 81e265582b9f338f7e2ef4c1ba206130b6759544a0b0ecc009ebb3b5154c6389458f7aa61b94bbac9e3b7f1d0febde08d45551ac06bf5d4289cdec398ae5e188
7
+ data.tar.gz: 631c33cbbbc9ecfb9f6f72ebe29b74ac040ed0c99f500a62e4e38ac1b7e1f37bd79edaf424ee2d78144f31d5f8efece27f4401b8245d8091b6e82a0fab7faf4f
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ Gemfile.lock
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Sidekiq::Haron
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sidekiq/haron`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Transfer some metadata to sidekiq job, can tag sidekiq logs and add logging job args. Example request_id or other request info.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,43 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Аdd to project class inheriting from `Sidekiq::Haron::Transmitter` like this:
24
+
25
+ ```ruby
26
+ class HaronTransmitter < Sidekiq::Haron::Transmitter
27
+
28
+ def saved_data *args
29
+ {
30
+ request_id: Current.request_id,
31
+ parent_request_id: Current.parent_request_id
32
+ }
33
+ end
34
+
35
+ def load_data hash
36
+ Current.request_id = hash['request_id'].presence || SecureRandom.hex
37
+ Current.parent_request_id = hash['parent_request_id']
38
+ end
39
+
40
+ def tags
41
+ [Current.parent_request_id]
42
+ end
43
+
44
+ end
45
+ ```
46
+
47
+ Аdd to `config/initializers/sidekiq.rb`:
48
+
49
+ ```ruby
50
+ Sidekiq::Haron.install(HaronTransmitter)
51
+ ```
52
+
53
+ Now all your sidekiq log have `Current.parent_request_id` value as tag and log job args too:
54
+
55
+ ```
56
+ 2020-01-14T14:22:09.035Z TestWorker JID-940645f14b345b3b4031d1cc I: [4f445354] with args [1, {"q"=>2}]
57
+ 2020-01-14T14:22:09.035Z TestWorker JID-940645f14b345b3b4031d1cc I: [4f445354] start
58
+ 2020-01-14T14:22:09.041Z TestWorker JID-940645f14b345b3b4031d1cc I: [4f445354] done: 0.006 sec
59
+ ```
26
60
 
27
61
  ## Development
28
62
 
@@ -32,7 +66,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
66
 
33
67
  ## Contributing
34
68
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sidekiq-haron.
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Rnd-Soft/sidekiq-haron.
36
70
 
37
71
  ## License
38
72
 
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tttt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,3 +1,4 @@
1
+ require 'sidekiq'
1
2
  require 'sidekiq/haron/formatter'
2
3
  require 'sidekiq/haron/storage'
3
4
  require 'sidekiq/haron/transmitter'
@@ -10,7 +11,13 @@ require 'sidekiq/haron/version'
10
11
  module Sidekiq
11
12
  module Haron
12
13
 
13
- mattr_accessor :transmitter
14
+ def self.transmitter
15
+ Sidekiq.options[:transmitter]
16
+ end
17
+
18
+ def self.transmitter= v
19
+ Sidekiq.options[:transmitter] = v
20
+ end
14
21
 
15
22
  def self.install transmitter_class
16
23
  Sidekiq::Haron.transmitter = transmitter_class.new
@@ -1,3 +1,4 @@
1
+ require 'sidekiq/exception_handler'
1
2
  class Sidekiq::Haron::ExceptionLogger < Sidekiq::ExceptionHandler::Logger
2
3
 
3
4
  def self.install
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Haron
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["wolferingys@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Transfer some data to sidekiq job and can tag sidekiq logs}
13
- spec.description = %q{Transfer some data to sidekiq job and can tag sidekiq logs}
13
+ spec.description = %q{Transfer some metadata to sidekiq job, can tag sidekiq logs and add logging job args}
14
14
  spec.homepage = "https://github.com/Rnd-Soft/sidekiq-haron"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-haron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serg F
@@ -94,7 +94,8 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Transfer some data to sidekiq job and can tag sidekiq logs
97
+ description: Transfer some metadata to sidekiq job, can tag sidekiq logs and add logging
98
+ job args
98
99
  email:
99
100
  - wolferingys@gmail.com
100
101
  executables: []
@@ -107,6 +108,8 @@ files:
107
108
  - LICENSE.txt
108
109
  - README.md
109
110
  - Rakefile
111
+ - bin/console
112
+ - bin/setup
110
113
  - lib/sidekiq/haron.rb
111
114
  - lib/sidekiq/haron/client_middleware.rb
112
115
  - lib/sidekiq/haron/exception_logger.rb