work_shaper 0.1.0 → 0.1.1

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: 5f008d410f5dc96fc854d8673b38873eacb66d176768d8c8ab8b78107a4b4837
4
- data.tar.gz: 621935ffcad5cd2db1b138a2fafeab86eeb5c86138437756a56768cae698a1ff
3
+ metadata.gz: de4165a0ac67a037a6b86382d259eb01851d453b7d0612ca7ea7be964825a101
4
+ data.tar.gz: 25834ee43b2ed420fa913d426e00a268846b473bf69c6efd2651e8c705ca8aa2
5
5
  SHA512:
6
- metadata.gz: 2119feac5a3f1d5e56d69b572a8b764558625d68da7c63d7b7fa4e2747e92a204013fea4247cd5502317fed446ebb7f8826b130f9f15437895de2547a4c927d2
7
- data.tar.gz: 591f2a06d61f872e1d194b73dfac057f31b34f903512ba48b6864e9280d71b27ed83004e95274d4dd029ce978853f0dd81b126c5b5eb8e28014a3e9c169f89be
6
+ metadata.gz: ccfa851b800c7f4a97ffa789df95297e44814f06d0348ae8e4a97b768b156b751c15c7da746ce22c5e4ebaf253721e15d8763dc1c9a2814a82af5f3a72d529c6
7
+ data.tar.gz: b3edfcbf33fa35c9ad4632a9e61dcb84b3ac6a437b240074b65290e9b7a3d2b76249e1ee7e0fddc21d9e50cecce6d513ecca5a75a6b95645c548714faa49c9cb
data/README.md CHANGED
@@ -60,7 +60,13 @@ end
60
60
 
61
61
  max_in_queue = ENV.fetch('MAX_THREAD_QUEUE_SIZE', 25)
62
62
 
63
- work_shaper = WorkShaper::Manager.new(work, done, ack, error, max_in_queue)
63
+ work_shaper = WorkShaper::Manager.new(
64
+ work: work,
65
+ on_done: done,
66
+ ack: ack,
67
+ on_error: error,
68
+ max_in_queue: max_in_queue
69
+ )
64
70
 
65
71
  @value_to_subkey = {}
66
72
  max_sub_keys = ENV.fetch('MAX_SUB_KEYS', 100)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkShaper
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/work_shaper.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative "work_shaper/version"
4
4
  require_relative "work_shaper/manager"
5
5
  require_relative "work_shaper/worker"
6
+ require 'json'
6
7
 
7
8
  # WorkShaper is inspired by Kafka partitions and offsets, but could be used to organize and
8
9
  # parallelize other forms of work. The original goal was to parallelize processing offsets in
@@ -18,12 +19,25 @@ module WorkShaper
18
19
  def self.logger=(logger)
19
20
  @logger = logger
20
21
  end
22
+
21
23
  def self.logger
22
24
  @logger ||= Logger.new(
23
25
  $stdout,
24
26
  level: ENV['LOG_LEVEL'] || 'DEBUG',
25
- formatter: Ruby::JSONFormatter::Base.new
27
+ formatter: formatter
26
28
  )
27
29
  end
30
+
31
+ def self.formatter
32
+ proc do |severity, datetime, _progname, msg|
33
+ datefmt = datetime.strftime('%Y-%m-%dT%H:%M:%S.%6N')
34
+ {
35
+ timestamp: datefmt,
36
+ level: severity.ljust(5),
37
+ pid: Process.pid,
38
+ msg: msg
39
+ }.to_json + "\n"
40
+ end
41
+ end
28
42
  end
29
43
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_shaper
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
  - Jerry Fernholz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-02 00:00:00.000000000 Z
11
+ date: 2024-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorted_set