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.
- checksums.yaml +4 -4
- data/lib/tiny_work_service.rb +14 -5
- 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: 3c407366b783cb5229c15a319b4b39d38c1b505b200dde5ea2fa581b2e5d93bc
|
4
|
+
data.tar.gz: 4d30dbe1bbdcf2ce1b91d989f57e99220dbefbcf5665d41da7594901c584e85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d9443292f19c5eda19c346e440a1629ef9d37c9adb71ba6fdf5a1043672b16e728a71e79a1692a2168b00b5da2f1b3762fc1c057433fbe3d5e12146ddcae31b
|
7
|
+
data.tar.gz: 4b981c8db0d0ffad7fe20a744c361b776e66fa5029cc72c8feb95757a2643121012f84d2c5a8a72237140b1014261f58bbbcfe64940e8135b17d3e98e874a2a1
|
data/lib/tiny_work_service.rb
CHANGED
@@ -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
|
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
|
24
|
-
@jobs_per_hour = 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 "\
|
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:
|
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-
|
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
|