work_shaper 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/work_shaper/manager.rb +1 -1
- data/lib/work_shaper/version.rb +1 -1
- data/lib/work_shaper.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 357d650ad73cfb685d1fd05a2ed98a0b4136358dc232febe04be921f8954855c
|
4
|
+
data.tar.gz: 77bceccf96220ec5ba98e438fde84761dd3494878fae05005cccdad0121cb833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c75b8e97b6e320e57164a2128ab320b23efe22c81d3e3f64857e70f92ee3dd881133060b702109ec1b172120a446ffb8d214a0423a039eb95ac4a6d06b3de3
|
7
|
+
data.tar.gz: 72babc90aaef951eb50dcc3edea4bc71903497bc79aaf3c7708fc143649407a88d4df6240d5f3b232a60fc37f11446f758109d833bc65d0822a23578b2da7ee6
|
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(
|
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)
|
data/lib/work_shaper/manager.rb
CHANGED
@@ -155,11 +155,11 @@ module WorkShaper
|
|
155
155
|
received: @received_offsets[partition].to_a[0..10].join(',')
|
156
156
|
})
|
157
157
|
else
|
158
|
-
@total_acked += 1
|
159
158
|
@last_ack[partition] = offset
|
160
159
|
end
|
161
160
|
end
|
162
161
|
|
162
|
+
@total_acked += 1
|
163
163
|
completed.delete(offset)
|
164
164
|
received.delete(offset)
|
165
165
|
|
data/lib/work_shaper/version.rb
CHANGED
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:
|
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.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2024-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorted_set
|