procon_bypass_man 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +6 -6
- data/.rubocop.yml +4 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -6
- data/Steepfile +0 -1
- data/docs/getting_started.md +48 -20
- data/docs/setup_raspi_by_mitamae.md +44 -2
- data/lib/procon_bypass_man/background/job_performer.rb +1 -2
- data/lib/procon_bypass_man/background/job_queue.rb +50 -0
- data/lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb +2 -2
- data/lib/procon_bypass_man/background/jobs/concerns/job_performable.rb +2 -2
- data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_error_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb +43 -0
- data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_start_reboot_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb +1 -1
- data/lib/procon_bypass_man/background.rb +2 -3
- data/lib/procon_bypass_man/bypass/bypass_command.rb +6 -15
- data/lib/procon_bypass_man/bypass/bypass_value.rb +6 -0
- data/lib/procon_bypass_man/bypass/procon_to_switch.rb +107 -0
- data/lib/procon_bypass_man/bypass/switch_to_procon.rb +64 -0
- data/lib/procon_bypass_man/bypass.rb +5 -110
- data/lib/procon_bypass_man/configuration.rb +15 -39
- data/lib/procon_bypass_man/device_connection/procon_setting_overrider.rb +12 -3
- data/lib/procon_bypass_man/procon/macro.rb +1 -1
- data/lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb +17 -0
- data/lib/procon_bypass_man/procon/performance_measurement/measurement_collection.rb +9 -0
- data/lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb +84 -0
- data/lib/procon_bypass_man/procon/performance_measurement/procon_performance_span_transfer_job.rb +8 -0
- data/lib/procon_bypass_man/procon/performance_measurement/queue_over_process.rb +38 -0
- data/lib/procon_bypass_man/procon/performance_measurement/span_queue.rb +42 -0
- data/lib/procon_bypass_man/procon/performance_measurement/span_transfer_buffer.rb +39 -0
- data/lib/procon_bypass_man/procon/performance_measurement.rb +103 -0
- data/lib/procon_bypass_man/procon.rb +2 -1
- data/lib/procon_bypass_man/procon_display/bypass_hook.rb +4 -3
- data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +26 -44
- data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +22 -24
- data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +1 -1
- data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +1 -1
- data/lib/procon_bypass_man/remote_macro/task.rb +1 -5
- data/lib/procon_bypass_man/remote_macro/task_queue.rb +6 -10
- data/lib/procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command.rb +1 -1
- data/lib/procon_bypass_man/runner.rb +4 -10
- data/lib/procon_bypass_man/scheduler.rb +15 -6
- data/lib/procon_bypass_man/support/callbacks.rb +8 -4
- data/lib/procon_bypass_man/support/can_over_process.rb +60 -0
- data/lib/procon_bypass_man/support/gc.rb +8 -0
- data/lib/procon_bypass_man/support/http_client.rb +9 -6
- data/lib/procon_bypass_man/support/load_agv.rb +20 -0
- data/lib/procon_bypass_man/support/procon_performance_http_client.rb +7 -0
- data/lib/procon_bypass_man/support/retryable.rb +16 -0
- data/lib/procon_bypass_man/support/signal_handler.rb +1 -1
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/client.rb +2 -2
- data/lib/procon_bypass_man/worker.rb +32 -0
- data/lib/procon_bypass_man.rb +40 -10
- data/project_template/app.rb +4 -6
- data/project_template/app.rb.erb +4 -6
- data/sig/main.rbs +10 -52
- metadata +21 -8
- data/lib/procon_bypass_man/background/job_runner.rb +0 -45
- data/lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb +0 -5
- data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +0 -15
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +0 -43
- data/lib/procon_bypass_man/io_monitor.rb +0 -108
- data/lib/procon_bypass_man/support/server_pool.rb +0 -46
@@ -1,108 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
class NullCounter
|
3
|
-
def initialize(label: )
|
4
|
-
end
|
5
|
-
|
6
|
-
def record(_)
|
7
|
-
end
|
8
|
-
|
9
|
-
def shutdown
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Counter
|
14
|
-
attr_accessor :label, :table, :previous_table, :active
|
15
|
-
|
16
|
-
def initialize(label: )
|
17
|
-
self.label = label
|
18
|
-
self.table = {}
|
19
|
-
self.previous_table = {}
|
20
|
-
self.active = true
|
21
|
-
end
|
22
|
-
|
23
|
-
# アクティブなバケットは1つだけ
|
24
|
-
def record(event_name)
|
25
|
-
key = Time.now.strftime("%S").to_i
|
26
|
-
if table[key].nil?
|
27
|
-
self.previous_table = table.values.first
|
28
|
-
self.table = {}
|
29
|
-
table[key] = {}
|
30
|
-
end
|
31
|
-
if table[key][event_name].nil?
|
32
|
-
table[key][event_name] = 1
|
33
|
-
else
|
34
|
-
table[key][event_name] += 1
|
35
|
-
end
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
def formatted_previous_table
|
40
|
-
t = previous_table.dup
|
41
|
-
start_function = t[:start_function] || 0
|
42
|
-
end_function = t[:end_function] || 0
|
43
|
-
eagain_wait_readable_on_read = t[:eagain_wait_readable_on_read] || 0
|
44
|
-
eagain_wait_readable_on_write = t[:eagain_wait_readable_on_write] || 0
|
45
|
-
"(#{(end_function / start_function.to_f * 100).floor(1)}%(#{end_function}/#{start_function}), loss: #{eagain_wait_readable_on_read}, #{eagain_wait_readable_on_write})"
|
46
|
-
end
|
47
|
-
|
48
|
-
def shutdown
|
49
|
-
self.active = false
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
module IOMonitor
|
54
|
-
@@thread = nil
|
55
|
-
|
56
|
-
def self.new(label: )
|
57
|
-
return NullCounter.new(label: label) if not started?
|
58
|
-
|
59
|
-
counter = Counter.new(label: label)
|
60
|
-
@@list << counter
|
61
|
-
counter
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [Array<Counter>]
|
65
|
-
def self.targets
|
66
|
-
@@list
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.started?
|
70
|
-
!!@@thread
|
71
|
-
end
|
72
|
-
|
73
|
-
# ここで集計する
|
74
|
-
def self.start!
|
75
|
-
@@thread = Thread.start do
|
76
|
-
max_output_length = 0
|
77
|
-
loop do
|
78
|
-
list = @@list.select(&:active).dup
|
79
|
-
unless list.all? { |x| x&.previous_table.is_a?(Hash) }
|
80
|
-
sleep 0.5
|
81
|
-
next
|
82
|
-
end
|
83
|
-
|
84
|
-
line = list.map { |counter|
|
85
|
-
"#{counter.label}(#{counter.formatted_previous_table})"
|
86
|
-
}.join(", ")
|
87
|
-
max_output_length = line.length
|
88
|
-
sleep 0.7
|
89
|
-
|
90
|
-
if ENV["PBM_FOREGROUND"]
|
91
|
-
print "\r"
|
92
|
-
print " " * max_output_length
|
93
|
-
print "\r"
|
94
|
-
print line
|
95
|
-
end
|
96
|
-
ProconBypassMan.logger.debug { line }
|
97
|
-
break if $will_terminate_token
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def self.reset!
|
103
|
-
@@list = []
|
104
|
-
end
|
105
|
-
|
106
|
-
reset!
|
107
|
-
end
|
108
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
class ServerPool
|
3
|
-
def initialize(servers: )
|
4
|
-
if servers.nil? || servers.empty?
|
5
|
-
return
|
6
|
-
end
|
7
|
-
|
8
|
-
@servers = servers
|
9
|
-
if @servers.size >= 1
|
10
|
-
@index = 0
|
11
|
-
else
|
12
|
-
@index = nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def pick
|
17
|
-
if @index.nil?
|
18
|
-
return @servers&.first
|
19
|
-
end
|
20
|
-
@servers[@index] or raise "bug!!!"
|
21
|
-
end
|
22
|
-
def server; pick; end
|
23
|
-
|
24
|
-
def next!
|
25
|
-
inc_index
|
26
|
-
if @servers[@index].nil?
|
27
|
-
reset
|
28
|
-
return
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def reset
|
35
|
-
@index = 0
|
36
|
-
end
|
37
|
-
|
38
|
-
def inc_index
|
39
|
-
@index = @index + 1
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if $0 == __FILE__
|
45
|
-
ProconBypassMan::ServerPool.new(servers: ['http://example.com'])
|
46
|
-
end
|