tiny_work_service 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_work_service.rb +13 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7c5571b2bf724aef7555d8c11de715b7f2d3a8c615e319b9464a0a13f10b33d
4
- data.tar.gz: e8b2ff42e033f913bfd46e9d0120cba2fdf7c067782c98e0c6e2df96b22e9bd9
3
+ metadata.gz: 6f03cbc2ef873707377dd8d5cc854cedfac5bc284e66a027cdb5fcd99f6c0797
4
+ data.tar.gz: 748a6d635f5680107a7b8f9afdcc46ca16db86a3e53db3dd6ce942e4894c9ad1
5
5
  SHA512:
6
- metadata.gz: bb3937d747d331b33ab3cbefd16c6d98550274cc0bb6068b1fb5155e8b7b7e0c09d99c50dd2dd504d065930afc484b3e3800694d0fb93f1807dde0055c10a3b6
7
- data.tar.gz: 231760d6718b704206986b94e8123667af07726946b3bc68d4fc32766dff6f38b34a4b258ffd09bfad5b0ef436e50a49decd68591669e3864787d09f7d46ef95
6
+ metadata.gz: 62dd8cb1257265507eea8d6910d677528ae7e35917342c7733186a497393d8fbdbf7d53d1ee4daba02d6e016c40cff32383c7ae758f685084392ee14e336602d
7
+ data.tar.gz: 21e4c97697d3b1c28397ed3012e5f1c26f394771843bd98ff37fd5aa1454fc6a5813f12187376abe5f2b053685a117a6f3b04b7eda5da851c005938cf1f33a17
@@ -10,11 +10,12 @@ class TinyWorkService
10
10
  :jobs_per_minute,
11
11
  :jobs_per_hour
12
12
 
13
- def initialize(port, label)
13
+ def initialize(port, label, refresh_interval_in_seconds)
14
14
  @service = TinyTCPService.new(port)
15
15
  @service.msg_handler = self
16
16
  @jobs = Queue.new
17
17
  @label = label
18
+ @label_and_port = "#{@label}:#{port}"
18
19
 
19
20
  @jobs_enqueued = 0
20
21
  @jobs_dequeued = 0
@@ -26,18 +27,22 @@ class TinyWorkService
26
27
 
27
28
  # status printing thread
28
29
  Thread.new do
30
+ start_time = Time.now
29
31
  print "\e[?25l" # hide cursor
30
32
  loop do
31
33
  break unless @service.running?
34
+ sec_runtime = Time.now - start_time
35
+ human_runtime = "%02d:%02d:%02d" % [sec_runtime / 3600, sec_runtime / 60 % 60, sec_runtime % 60]
32
36
 
33
37
  print "\e[1;1H"
34
- puts "#{DateTime.now.iso8601}\e[K"
35
- puts "#{@label}:#{port}\e[K"
36
- puts "workers :#{@service.num_clients.to_s.rjust(10)}\e[K"
37
- puts "queue :#{@jobs.length.to_s.rjust(10)}\e[K"
38
- puts "jobs/m :#{@jobs_per_minute.to_s.rjust(10)}\e[K"
39
- print "jobs/h :#{@jobs_per_hour.to_s.rjust(10)}\e[K"
40
- sleep 0.5
38
+ puts "label/port: #{@label_and_port.rjust(28)}\e[K"
39
+ puts "time : #{DateTime.now.iso8601.rjust(28)}\e[K"
40
+ puts "runtime : #{human_runtime.rjust(28)}\e[K"
41
+ puts "workers : #{@service.num_clients.to_s.rjust(28)}\e[K"
42
+ puts "queue : #{@jobs.length.to_s.rjust(28)}\e[K"
43
+ puts "jobs/m : #{@jobs_per_minute.to_s.rjust(28)}\e[K"
44
+ print "jobs/h : #{@jobs_per_hour.to_s.rjust(28)}\e[K"
45
+ sleep refresh_interval_in_seconds
41
46
  end
42
47
  print "\e[?25h" # show cursor
43
48
  end
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: 2.0.1
4
+ version: 3.0.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: 2023-11-12 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tiny_tcp_service