tiny_work_service 3.1.0 → 3.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/tiny_work_service.rb +13 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086d55b6efeb017e4a317f204603941bd9d7abdd006dcf02f58884f7420a41d1'
|
4
|
+
data.tar.gz: 190e89bd6a264d8046dd162f534b9997b0d9cd1cc1d9052c2e366056e92771c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b13d7825cec5fbbbad362be740a7cec0009610bc365d47aaf5ce83aefc2324fb7f5cb3b154db156cf45924df5d0ec4a2c431822bbbde7d7f2325e592d86c83f
|
7
|
+
data.tar.gz: f6ec41a234d9b31b62f8564c488bd0fb3a25e4cd825f1e499846353ca480d797808a5a3f21fe4d97e328640e99d1ad886ac04aebab856932665ce7b42da67357
|
data/lib/tiny_work_service.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'tiny_tcp_service'
|
3
|
+
require 'tiny_eta'
|
3
4
|
|
4
5
|
# usage:
|
5
6
|
# s = TinyWorkService.new(1234, 'TinyWorkService')
|
@@ -25,6 +26,8 @@ class TinyWorkService
|
|
25
26
|
@jobs_per_minute = 0
|
26
27
|
@jobs_per_hour = 0
|
27
28
|
@errors_total = 0
|
29
|
+
@last_insert_time = Time.now
|
30
|
+
@last_insert_queue_count = [@jobs.length, 1].max
|
28
31
|
|
29
32
|
# status printing thread
|
30
33
|
Thread.new do
|
@@ -34,6 +37,9 @@ class TinyWorkService
|
|
34
37
|
break unless @service.running?
|
35
38
|
sec_runtime = Time.now - start_time
|
36
39
|
human_runtime = "%02d:%02d:%02d" % [sec_runtime / 3600, sec_runtime / 60 % 60, sec_runtime % 60]
|
40
|
+
elapsed_time_since_last_insert = Time.now - @last_insert_time
|
41
|
+
jobs_completed_since_last_insert = @last_insert_queue_count - @jobs.length
|
42
|
+
percent_completed_since_last_insert = jobs_completed_since_last_insert / @last_insert_queue_count.to_f
|
37
43
|
|
38
44
|
print "\e[1;1H"
|
39
45
|
puts "label/port: #{@label_and_port.rjust(28)}\e[K"
|
@@ -43,7 +49,9 @@ class TinyWorkService
|
|
43
49
|
puts "queue : #{@jobs.length.to_s.rjust(28)}\e[K"
|
44
50
|
puts "jobs/m : #{@jobs_per_minute.to_s.rjust(28)}\e[K"
|
45
51
|
puts "jobs/h : #{@jobs_per_hour.to_s.rjust(28)}\e[K"
|
46
|
-
|
52
|
+
puts "errors : #{@errors_total.to_s.rjust(28)}\e[K"
|
53
|
+
print "eta : #{TinyEta.eta(elapsed_time_since_last_insert, percent_completed_since_last_insert ).rjust(28)}\e[K"
|
54
|
+
|
47
55
|
sleep refresh_interval_in_seconds
|
48
56
|
end
|
49
57
|
print "\e[?25h" # show cursor
|
@@ -89,6 +97,10 @@ class TinyWorkService
|
|
89
97
|
case
|
90
98
|
when m[0] == '+' # add a job to the queue
|
91
99
|
self << m[1..]
|
100
|
+
|
101
|
+
@last_insert_time = Time.now
|
102
|
+
@last_insert_queue_count = @jobs.length
|
103
|
+
|
92
104
|
'ok' # ok, job received
|
93
105
|
when m[0] == '-' # take a job from the queue
|
94
106
|
shift || ''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_work_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_tcp_service
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tiny_eta
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
27
41
|
description: uses the tiny_tcp_service gem to implement a network job queue
|
28
42
|
email: jefflunt@gmail.com
|
29
43
|
executables: []
|