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 +4 -4
- data/README.md +7 -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: de4165a0ac67a037a6b86382d259eb01851d453b7d0612ca7ea7be964825a101
|
4
|
+
data.tar.gz: 25834ee43b2ed420fa913d426e00a268846b473bf69c6efd2651e8c705ca8aa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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/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.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-
|
11
|
+
date: 2024-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorted_set
|