tiny_work_service 1.4.0 → 2.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 +14 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64ea8638eba6ebc22945d5c80631513c30d8866519b973e04d66a6a247e408c0
4
- data.tar.gz: '099b5c7719d958f0674f1449d8da62d9de10fe66720b28aa0078c78f0c72bbf0'
3
+ metadata.gz: 3c407366b783cb5229c15a319b4b39d38c1b505b200dde5ea2fa581b2e5d93bc
4
+ data.tar.gz: 4d30dbe1bbdcf2ce1b91d989f57e99220dbefbcf5665d41da7594901c584e85f
5
5
  SHA512:
6
- metadata.gz: a68228cd855eeeb8943a20b87a12cb0b62f1bb6b9737251376a388eff7e08e5fa783fd2d0f5150eebb8d5c7237349d8abfe82568d59664c0a7140030b86cce15
7
- data.tar.gz: b0a7f962ccac5be3a45c0869bae4432336547a411669b8cf3950751d31a67ac841c47adf13e86def1b046686b188f108e4cb79c3a9c8f7296d5dd8aeeb05bab0
6
+ metadata.gz: 9d9443292f19c5eda19c346e440a1629ef9d37c9adb71ba6fdf5a1043672b16e728a71e79a1692a2168b00b5da2f1b3762fc1c057433fbe3d5e12146ddcae31b
7
+ data.tar.gz: 4b981c8db0d0ffad7fe20a744c361b776e66fa5029cc72c8feb95757a2643121012f84d2c5a8a72237140b1014261f58bbbcfe64940e8135b17d3e98e874a2a1
@@ -1,7 +1,8 @@
1
+ require 'time'
1
2
  require 'tiny_tcp_service'
2
3
 
3
4
  # usage:
4
- # s = TinyWorkService.new(1234)
5
+ # s = TinyWorkService.new(1234, 'TinyWorkService')
5
6
  # s.stop!
6
7
  class TinyWorkService
7
8
  attr_reader :jobs_enqueued,
@@ -9,7 +10,7 @@ class TinyWorkService
9
10
  :jobs_per_minute,
10
11
  :jobs_per_hour
11
12
 
12
- def initialize(port, label='TinyWorkService')
13
+ def initialize(port, label)
13
14
  @service = TinyTCPService.new(port)
14
15
  @service.msg_handler = self
15
16
  @jobs = Queue.new
@@ -20,17 +21,25 @@ class TinyWorkService
20
21
  @jobs_to_track = Queue.new
21
22
  @jobs_dequeued_tracker = []
22
23
 
23
- @jobs_per_minute = 0.0
24
- @jobs_per_hour = 0.0
24
+ @jobs_per_minute = 0
25
+ @jobs_per_hour = 0
25
26
 
26
27
  # status printing thread
27
28
  Thread.new do
29
+ print "\e[?25l" # hide cursor
28
30
  loop do
29
31
  break unless @service.running?
30
32
 
31
- print "\r#{@label}:#{port} jobs:#{@jobs.length.to_s} workers:#{@service.num_clients.to_s} jobs/m:#{@jobs_per_minute} jobs/h:#{@jobs_per_hour}\e[K"
33
+ print "\e[1;1H"
34
+ puts "#{DateTime.now.iso8601}\e[K"
35
+ puts "#{@label} on port #{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"
32
40
  sleep 0.5
33
41
  end
42
+ print "\e[?25h" # show cursor
34
43
  end
35
44
 
36
45
  # update stats thread
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: 1.4.0
4
+ version: 2.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-10 00:00:00.000000000 Z
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tiny_tcp_service