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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +6 -6
  3. data/.rubocop.yml +4 -0
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile.lock +1 -1
  7. data/README.md +15 -6
  8. data/Steepfile +0 -1
  9. data/docs/getting_started.md +48 -20
  10. data/docs/setup_raspi_by_mitamae.md +44 -2
  11. data/lib/procon_bypass_man/background/job_performer.rb +1 -2
  12. data/lib/procon_bypass_man/background/job_queue.rb +50 -0
  13. data/lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb +2 -2
  14. data/lib/procon_bypass_man/background/jobs/concerns/job_performable.rb +2 -2
  15. data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +1 -1
  16. data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +1 -1
  17. data/lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb +1 -1
  18. data/lib/procon_bypass_man/background/jobs/report_error_job.rb +1 -1
  19. data/lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb +1 -1
  20. data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +1 -1
  21. data/lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb +43 -0
  22. data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +1 -1
  23. data/lib/procon_bypass_man/background/jobs/report_start_reboot_job.rb +1 -1
  24. data/lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb +1 -1
  25. data/lib/procon_bypass_man/background.rb +2 -3
  26. data/lib/procon_bypass_man/bypass/bypass_command.rb +6 -15
  27. data/lib/procon_bypass_man/bypass/bypass_value.rb +6 -0
  28. data/lib/procon_bypass_man/bypass/procon_to_switch.rb +107 -0
  29. data/lib/procon_bypass_man/bypass/switch_to_procon.rb +64 -0
  30. data/lib/procon_bypass_man/bypass.rb +5 -110
  31. data/lib/procon_bypass_man/configuration.rb +15 -39
  32. data/lib/procon_bypass_man/device_connection/procon_setting_overrider.rb +12 -3
  33. data/lib/procon_bypass_man/procon/macro.rb +1 -1
  34. data/lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb +17 -0
  35. data/lib/procon_bypass_man/procon/performance_measurement/measurement_collection.rb +9 -0
  36. data/lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb +84 -0
  37. data/lib/procon_bypass_man/procon/performance_measurement/procon_performance_span_transfer_job.rb +8 -0
  38. data/lib/procon_bypass_man/procon/performance_measurement/queue_over_process.rb +38 -0
  39. data/lib/procon_bypass_man/procon/performance_measurement/span_queue.rb +42 -0
  40. data/lib/procon_bypass_man/procon/performance_measurement/span_transfer_buffer.rb +39 -0
  41. data/lib/procon_bypass_man/procon/performance_measurement.rb +103 -0
  42. data/lib/procon_bypass_man/procon.rb +2 -1
  43. data/lib/procon_bypass_man/procon_display/bypass_hook.rb +4 -3
  44. data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +26 -44
  45. data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +22 -24
  46. data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +1 -1
  47. data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +1 -1
  48. data/lib/procon_bypass_man/remote_macro/task.rb +1 -5
  49. data/lib/procon_bypass_man/remote_macro/task_queue.rb +6 -10
  50. data/lib/procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command.rb +1 -1
  51. data/lib/procon_bypass_man/runner.rb +4 -10
  52. data/lib/procon_bypass_man/scheduler.rb +15 -6
  53. data/lib/procon_bypass_man/support/callbacks.rb +8 -4
  54. data/lib/procon_bypass_man/support/can_over_process.rb +60 -0
  55. data/lib/procon_bypass_man/support/gc.rb +8 -0
  56. data/lib/procon_bypass_man/support/http_client.rb +9 -6
  57. data/lib/procon_bypass_man/support/load_agv.rb +20 -0
  58. data/lib/procon_bypass_man/support/procon_performance_http_client.rb +7 -0
  59. data/lib/procon_bypass_man/support/retryable.rb +16 -0
  60. data/lib/procon_bypass_man/support/signal_handler.rb +1 -1
  61. data/lib/procon_bypass_man/version.rb +1 -1
  62. data/lib/procon_bypass_man/websocket/client.rb +2 -2
  63. data/lib/procon_bypass_man/worker.rb +32 -0
  64. data/lib/procon_bypass_man.rb +40 -10
  65. data/project_template/app.rb +4 -6
  66. data/project_template/app.rb.erb +4 -6
  67. data/sig/main.rbs +10 -52
  68. metadata +21 -8
  69. data/lib/procon_bypass_man/background/job_runner.rb +0 -45
  70. data/lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb +0 -5
  71. data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +0 -15
  72. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +0 -43
  73. data/lib/procon_bypass_man/io_monitor.rb +0 -108
  74. data/lib/procon_bypass_man/support/server_pool.rb +0 -46
@@ -0,0 +1,16 @@
1
+ module ProconBypassMan
2
+ class Retryable
3
+ def self.retryable(tries: , retried: 0, on_no_retry: [])
4
+ return yield(retried)
5
+ rescue *on_no_retry
6
+ raise
7
+ rescue
8
+ if tries <= retried
9
+ raise
10
+ else
11
+ retried = retried + 1
12
+ retry
13
+ end
14
+ end
15
+ end
16
+ end
@@ -3,7 +3,7 @@ module ProconBypassMan::SignalHandler
3
3
  ProconBypassMan.logger.info "#{$$}で#{sig}を受け取りました"
4
4
  case sig
5
5
  when 'USR2'
6
- raise ProconBypassMan::Runner::InterruptForRestart
6
+ raise ProconBypassMan::InterruptForRestart
7
7
  when 'INT', 'TERM'
8
8
  raise Interrupt
9
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProconBypassMan
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
@@ -99,11 +99,11 @@ module ProconBypassMan
99
99
  def self.validate_and_run_remote_macro(data: )
100
100
  pbm_job_hash = data.dig("message")
101
101
  begin
102
- remote_macro_object = ProconBypassMan::RemoteMacroObject.new(name: pbm_job_hash["name"],
102
+ remote_macro_object = ProconBypassMan::RemoteMacro::RemoteMacroObject.new(name: pbm_job_hash["name"],
103
103
  uuid: pbm_job_hash["uuid"],
104
104
  steps: pbm_job_hash["steps"])
105
105
  remote_macro_object.validate!
106
- rescue ProconBypassMan::RemoteMacroObject::ValidationError => e
106
+ rescue ProconBypassMan::RemoteMacro::RemoteMacroObject::ValidationError => e
107
107
  ProconBypassMan::SendErrorCommand.execute(error: e)
108
108
  return
109
109
  end
@@ -0,0 +1,32 @@
1
+ module ProconBypassMan
2
+ class Worker
3
+ attr_accessor :pid
4
+
5
+ def self.run
6
+ new.run
7
+ end
8
+
9
+ # @param [Boolean]
10
+ def run
11
+ return self if @thread
12
+ @thread = Thread.new do
13
+ while(item = ProconBypassMan::Background::JobQueue.pop)
14
+ begin
15
+ # プロセスを越えるので、文字列でenqueueしてくれる前提. evalしてクラスにする
16
+ ProconBypassMan::Background::JobPerformer.new(klass: eval(item[:job_class]), args: item[:args]).perform
17
+ rescue => e
18
+ ProconBypassMan.logger.error(e)
19
+ sleep(0.2) # busy loopしないように
20
+ end
21
+ end
22
+ end
23
+
24
+ return self
25
+ end
26
+
27
+ # 重要な非同期ジョブは存在しないのでqueueが捌けるのを待たずにkill
28
+ def shutdown
29
+ @thread&.kill
30
+ end
31
+ end
32
+ end
@@ -12,8 +12,6 @@ require "resolv-replace"
12
12
  require "pbmenv"
13
13
 
14
14
  require_relative "procon_bypass_man/version"
15
- require_relative "procon_bypass_man/remote_pbm_action"
16
- require_relative "procon_bypass_man/remote_macro"
17
15
 
18
16
  require_relative "procon_bypass_man/device_connection"
19
17
  require_relative "procon_bypass_man/support/usb_device_controller"
@@ -26,16 +24,20 @@ require_relative "procon_bypass_man/support/yaml_writer"
26
24
  require_relative "procon_bypass_man/support/safe_timeout"
27
25
  require_relative "procon_bypass_man/support/compress_array"
28
26
  require_relative "procon_bypass_man/support/uptime"
27
+ require_relative "procon_bypass_man/support/load_agv"
29
28
  require_relative "procon_bypass_man/support/on_memory_cache"
30
29
  require_relative "procon_bypass_man/support/http_client"
31
30
  require_relative "procon_bypass_man/support/report_http_client"
32
31
  require_relative "procon_bypass_man/support/remote_macro_http_client"
33
32
  require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
34
33
  require_relative "procon_bypass_man/support/send_device_stats_http_client"
35
- require_relative "procon_bypass_man/support/server_pool"
34
+ require_relative "procon_bypass_man/support/procon_performance_http_client"
36
35
  require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
37
36
  require_relative "procon_bypass_man/support/never_exit_accidentally"
38
37
  require_relative "procon_bypass_man/support/cycle_sleep"
38
+ require_relative "procon_bypass_man/support/can_over_process"
39
+ require_relative "procon_bypass_man/support/gc"
40
+ require_relative "procon_bypass_man/support/retryable"
39
41
  require_relative "procon_bypass_man/procon_display"
40
42
  require_relative "procon_bypass_man/background"
41
43
  require_relative "procon_bypass_man/commands"
@@ -53,10 +55,14 @@ require_relative "procon_bypass_man/procon/analog_stick_manipulator"
53
55
  require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
54
56
  require_relative "procon_bypass_man/scheduler"
55
57
  require_relative "procon_bypass_man/plugins"
58
+ require_relative "procon_bypass_man/worker"
56
59
  require_relative "procon_bypass_man/websocket/client"
57
60
  require_relative "procon_bypass_man/websocket/watchdog"
58
61
  require_relative "procon_bypass_man/websocket/forever"
59
62
 
63
+ require_relative "procon_bypass_man/remote_pbm_action"
64
+ require_relative "procon_bypass_man/remote_macro"
65
+
60
66
  STDOUT.sync = true
61
67
  Thread.abort_on_exception = true
62
68
 
@@ -67,11 +73,18 @@ module ProconBypassMan
67
73
  class CouldNotLoadConfigError < StandardError; end
68
74
  class NotFoundProconError < StandardError; end
69
75
 
76
+ class InterruptForRestart < StandardError; end
77
+
78
+ class << self
79
+ attr_accessor :worker
80
+ end
81
+
70
82
  # @return [void]
71
83
  def self.run(setting_path: nil)
72
84
  ProconBypassMan::PrintMessageCommand.execute(text: "PBMを起動しています")
73
85
  initialize_pbm
74
86
 
87
+ # 設定ファイルの読み込み
75
88
  begin
76
89
  ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path)
77
90
  rescue ProconBypassMan::CouldNotLoadConfigError
@@ -84,6 +97,7 @@ module ProconBypassMan
84
97
  return
85
98
  end
86
99
 
100
+ # デバイスの接続フェーズ
87
101
  begin
88
102
  gadget, procon = ProconBypassMan::DeviceConnection::Command.execute!
89
103
  rescue ProconBypassMan::DeviceConnection::NotFoundProconError
@@ -95,7 +109,7 @@ module ProconBypassMan
95
109
  end
96
110
  return
97
111
  rescue ProconBypassMan::DeviceConnection::TimeoutError
98
- ProconBypassMan::SendErrorCommand.execute(error: "接続の見込みがないのでsleepしまくります")
112
+ ProconBypassMan::SendErrorCommand.execute(error: "接続に失敗しました。プロコンとRaspberry Piのケーブルを差し直して、再実行してください。\n改善しない場合は、app.logの中身を添えて不具合報告をお願いします。")
99
113
  ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
100
114
  %w(TERM INT).each do |sig|
101
115
  Kernel.trap(sig) { exit 0 }
@@ -131,33 +145,49 @@ module ProconBypassMan
131
145
  ProconBypassMan::Procon::ModeRegistry.reset!
132
146
  ProconBypassMan::Procon.reset!
133
147
  ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
134
- ProconBypassMan::IOMonitor.reset!
135
148
  end
136
149
 
137
150
  # @return [void]
138
151
  def self.initialize_pbm
139
- ProconBypassMan::Scheduler.start!
140
- ProconBypassMan::Background::JobRunner.start!
152
+ `renice -n 20 -p #{$$}`
153
+ ProconBypassMan::Background::JobQueue.start!
141
154
  ProconBypassMan::Websocket::Client.start!
142
- ProconBypassMan::QueueOverProcess.start!
155
+ # TODO ProconBypassMan::DrbObjects.start_all! みたいな感じで書きたい
156
+ ProconBypassMan::RemoteMacro::QueueOverProcess.start!
157
+ ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.start!
158
+ ProconBypassMan::Scheduler.start!
143
159
 
144
160
  ProconBypassMan::WriteDeviceIdCommand.execute
145
161
  ProconBypassMan::WriteSessionIdCommand.execute
146
- `renice -n -20 -p #{$$}`
147
162
  File.write(pid_path, $$)
148
163
  ProconBypassMan::DeviceStatus.change_to_running!
149
164
  end
150
165
 
166
+ # @return [void]
151
167
  def self.ready_pbm
152
168
  ProconBypassMan::PrintBootMessageCommand.execute
153
169
  ProconBypassMan::ReportLoadConfigJob.perform_async(ProconBypassMan.config.raw_setting)
170
+
171
+ self.worker = ProconBypassMan::Worker.run
172
+ end
173
+
174
+ # @return [void]
175
+ def self.after_fork_on_bypass_process
176
+ `renice -n -20 -p #{$$}`
177
+ ::GC.start
178
+ DRb.start_service if defined?(DRb)
179
+ ProconBypassMan::RemoteMacroReceiver.start!
180
+ ProconBypassMan::ProconDisplay::Server.start!
154
181
  end
155
182
 
156
183
  # @return [void]
157
184
  def self.terminate_pbm
158
185
  FileUtils.rm_rf(ProconBypassMan.pid_path)
159
186
  FileUtils.rm_rf(ProconBypassMan.digest_path)
160
- ProconBypassMan::QueueOverProcess.shutdown
187
+ ProconBypassMan::Background::JobQueue.shutdown
188
+ ProconBypassMan::RemoteMacro::QueueOverProcess.shutdown
189
+ ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.shutdown
190
+ self.worker&.shutdown
161
191
  end
162
192
 
163
193
  # @return [void]
@@ -12,7 +12,7 @@ begin
12
12
  gemfile do
13
13
  source 'https://rubygems.org'
14
14
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
15
- gem 'procon_bypass_man', '0.2.2'
15
+ gem 'procon_bypass_man', '0.2.3'
16
16
  end
17
17
  rescue Bundler::Source::Git::GitCommandError => e
18
18
  retry_count_on_git_command_error = retry_count_on_git_command_error + 1
@@ -37,8 +37,9 @@ ProconBypassMan.configure do |config|
37
37
  # バイパスするログを全部app.logに流すか
38
38
  config.verbose_bypass_log = false
39
39
 
40
- # webからProconBypassManを操作できるwebサービス
41
- # config.api_servers = ['https://pbm-cloud.herokuapp.com']
40
+ # webからProconBypassManを操作できるwebサービスと連携します
41
+ # 連携中はエラーログ、パフォーマンスに関するメトリクスを送信します
42
+ # config.api_servers = 'https://pbm-cloud.herokuapp.com'
42
43
 
43
44
  # エラーが起きたらerror.logに書き込みます
44
45
  config.enable_critical_error_logging = true
@@ -46,9 +47,6 @@ ProconBypassMan.configure do |config|
46
47
  # pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
47
48
  config.never_exit_accidentally = true
48
49
 
49
- # 毎秒行ったIOをログに出力するか
50
- config.io_monitor_logging = false
51
-
52
50
  # 接続に成功したらコントローラーのHOME LEDを光らせるか
53
51
  config.enable_home_led_on_connect = true
54
52
 
@@ -12,7 +12,7 @@ begin
12
12
  gemfile do
13
13
  source 'https://rubygems.org'
14
14
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
15
- gem 'procon_bypass_man', '0.2.2'
15
+ gem 'procon_bypass_man', '0.2.3'
16
16
  end
17
17
  rescue Bundler::Source::Git::GitCommandError => e
18
18
  retry_count_on_git_command_error = retry_count_on_git_command_error + 1
@@ -37,8 +37,9 @@ ProconBypassMan.configure do |config|
37
37
  # バイパスするログを全部app.logに流すか
38
38
  config.verbose_bypass_log = false
39
39
 
40
- # webからProconBypassManを操作できるwebサービス
41
- <%- api_server_config = "config.api_servers = ['https://pbm-cloud.herokuapp.com']" -%>
40
+ # webからProconBypassManを操作できるwebサービスと連携します
41
+ # 連携中はエラーログ、パフォーマンスに関するメトリクスを送信します
42
+ <%- api_server_config = "config.api_servers = 'https://pbm-cloud.herokuapp.com'" -%>
42
43
  <%- if enable_integration_with_pbm_cloud -%>
43
44
  <%= api_server_config %>
44
45
  <%- else -%>
@@ -51,9 +52,6 @@ ProconBypassMan.configure do |config|
51
52
  # pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
52
53
  config.never_exit_accidentally = true
53
54
 
54
- # 毎秒行ったIOをログに出力するか
55
- config.io_monitor_logging = false
56
-
57
55
  # 接続に成功したらコントローラーのHOME LEDを光らせるか
58
56
  config.enable_home_led_on_connect = true
59
57
 
data/sig/main.rbs CHANGED
@@ -174,6 +174,8 @@ class ProconBypassMan::Configuration
174
174
 
175
175
  def pid_path: () -> String
176
176
 
177
+ def worker_pid_path: () -> String
178
+
177
179
  def digest_path: () -> String
178
180
 
179
181
  def cache: () -> ProconBypassMan::OnMemoryCache
@@ -186,7 +188,6 @@ class ProconBypassMan::Configuration
186
188
  attr_reader api_server: untyped
187
189
  attr_reader api_servers: untyped
188
190
  attr_writer never_exit_accidentally: bool
189
- attr_writer io_monitor_logging: bool
190
191
 
191
192
  attr_accessor enable_critical_error_logging: bool
192
193
 
@@ -213,9 +214,13 @@ class ProconBypassMan::Configuration
213
214
 
214
215
  def enable_ws?: () -> bool
215
216
 
216
- def server_pool: () -> untyped
217
+ def has_api_server?: () -> bool
218
+
219
+ def enable_procon_performance_measurement?: () -> bool
217
220
 
218
- def internal_server_pool: () -> untyped
221
+ def server: () -> untyped
222
+
223
+ def internal_server: () -> untyped
219
224
 
220
225
  def internal_servers: () -> ::Array[string | nil]
221
226
 
@@ -226,8 +231,6 @@ class ProconBypassMan::Configuration
226
231
  def verbose_bypass_log: () -> bool
227
232
 
228
233
  def never_exit_accidentally: () -> bool
229
-
230
- def io_monitor_logging: () -> bool
231
234
  end
232
235
 
233
236
 
@@ -274,35 +277,6 @@ class ProconBypassMan::DeviceConnector
274
277
  def init_devices: () -> untyped
275
278
  end
276
279
 
277
- module ProconBypassMan
278
- class Counter
279
- attr_accessor label: untyped
280
-
281
- attr_accessor table: untyped
282
-
283
- attr_accessor previous_table: untyped
284
-
285
- def initialize: (label: untyped label) -> untyped
286
-
287
- # アクティブなバケットは1つだけ
288
- def record: (untyped event_name) -> untyped
289
-
290
- def formated_previous_table: () -> ::String
291
- end
292
-
293
- module IOMonitor
294
- def self.new: (label: untyped label) -> untyped
295
-
296
- # @return [Array<Counter>]
297
- def self.targets: () -> untyped
298
-
299
- # ここで集計する
300
- def self.start!: () -> untyped
301
-
302
- def self.reset!: () -> untyped
303
- end
304
- end
305
-
306
280
  class ProconBypassMan::Processor
307
281
  # @return [String] binary
308
282
  def initialize: (untyped binary) -> untyped
@@ -598,11 +572,11 @@ end
598
572
 
599
573
  module ProconBypassMan
600
574
  class HttpClient
601
- @server_pool: untyped
575
+ @server: untyped
602
576
  @uri: ::URI
603
577
  @retry_on_connection_error: false
604
578
 
605
- def initialize: (path: String, server_pool: untyped, ?retry_on_connection_error: false) -> void
579
+ def initialize: (path: String, server: untyped, ?retry_on_connection_error: false) -> void
606
580
  def get: -> nil
607
581
  def post: (request_body: untyped) -> nil
608
582
  def put: (request_body: untyped) -> nil
@@ -645,22 +619,6 @@ module ProconBypassMan
645
619
  end
646
620
  end
647
621
 
648
- module ProconBypassMan
649
- class ServerPool
650
- @servers: Array[String]
651
- @index: Integer?
652
-
653
- def initialize: (servers: Array[String]) -> void
654
- def pick: -> String?
655
- def server: -> String?
656
- def next!: -> nil
657
-
658
- private
659
- def reset: -> Integer
660
- def inc_index: -> Integer
661
- end
662
- end
663
-
664
622
  module ProconBypassMan
665
623
  class CompressArray
666
624
  @array: [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procon_bypass_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-10 00:00:00.000000000 Z
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pbmenv
@@ -94,10 +94,9 @@ files:
94
94
  - lib/procon_bypass_man.rb
95
95
  - lib/procon_bypass_man/background.rb
96
96
  - lib/procon_bypass_man/background/job_performer.rb
97
- - lib/procon_bypass_man/background/job_runner.rb
97
+ - lib/procon_bypass_man/background/job_queue.rb
98
98
  - lib/procon_bypass_man/background/jobs/base_job.rb
99
99
  - lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
100
- - lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
101
100
  - lib/procon_bypass_man/background/jobs/concerns/job_performable.rb
102
101
  - lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
103
102
  - lib/procon_bypass_man/background/jobs/report_boot_job.rb
@@ -106,7 +105,7 @@ files:
106
105
  - lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
107
106
  - lib/procon_bypass_man/background/jobs/report_event_base_job.rb
108
107
  - lib/procon_bypass_man/background/jobs/report_load_config_job.rb
109
- - lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb
108
+ - lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb
110
109
  - lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
111
110
  - lib/procon_bypass_man/background/jobs/report_start_reboot_job.rb
112
111
  - lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb
@@ -125,7 +124,9 @@ files:
125
124
  - lib/procon_bypass_man/buttons_setting_configuration/validator.rb
126
125
  - lib/procon_bypass_man/bypass.rb
127
126
  - lib/procon_bypass_man/bypass/bypass_command.rb
128
- - lib/procon_bypass_man/bypass/usb_hid_logger.rb
127
+ - lib/procon_bypass_man/bypass/bypass_value.rb
128
+ - lib/procon_bypass_man/bypass/procon_to_switch.rb
129
+ - lib/procon_bypass_man/bypass/switch_to_procon.rb
129
130
  - lib/procon_bypass_man/commands.rb
130
131
  - lib/procon_bypass_man/commands/print_boot_message_command.rb
131
132
  - lib/procon_bypass_man/commands/print_message_command.rb
@@ -146,7 +147,6 @@ files:
146
147
  - lib/procon_bypass_man/device_connection/spoofing_output_report_watcher.rb
147
148
  - lib/procon_bypass_man/device_model.rb
148
149
  - lib/procon_bypass_man/device_status.rb
149
- - lib/procon_bypass_man/io_monitor.rb
150
150
  - lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb
151
151
  - lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
152
152
  - lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb
@@ -171,6 +171,14 @@ files:
171
171
  - lib/procon_bypass_man/procon/macro_plugin_map.rb
172
172
  - lib/procon_bypass_man/procon/macro_registry.rb
173
173
  - lib/procon_bypass_man/procon/mode_registry.rb
174
+ - lib/procon_bypass_man/procon/performance_measurement.rb
175
+ - lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb
176
+ - lib/procon_bypass_man/procon/performance_measurement/measurement_collection.rb
177
+ - lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb
178
+ - lib/procon_bypass_man/procon/performance_measurement/procon_performance_span_transfer_job.rb
179
+ - lib/procon_bypass_man/procon/performance_measurement/queue_over_process.rb
180
+ - lib/procon_bypass_man/procon/performance_measurement/span_queue.rb
181
+ - lib/procon_bypass_man/procon/performance_measurement/span_transfer_buffer.rb
174
182
  - lib/procon_bypass_man/procon/press_button_aware.rb
175
183
  - lib/procon_bypass_man/procon/suppress_rumble.rb
176
184
  - lib/procon_bypass_man/procon/user_operation.rb
@@ -212,18 +220,22 @@ files:
212
220
  - lib/procon_bypass_man/scheduler.rb
213
221
  - lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
214
222
  - lib/procon_bypass_man/support/callbacks.rb
223
+ - lib/procon_bypass_man/support/can_over_process.rb
215
224
  - lib/procon_bypass_man/support/compress_array.rb
216
225
  - lib/procon_bypass_man/support/cycle_sleep.rb
217
226
  - lib/procon_bypass_man/support/device_mouse_finder.rb
218
227
  - lib/procon_bypass_man/support/device_procon_finder.rb
228
+ - lib/procon_bypass_man/support/gc.rb
219
229
  - lib/procon_bypass_man/support/http_client.rb
230
+ - lib/procon_bypass_man/support/load_agv.rb
220
231
  - lib/procon_bypass_man/support/never_exit_accidentally.rb
221
232
  - lib/procon_bypass_man/support/on_memory_cache.rb
233
+ - lib/procon_bypass_man/support/procon_performance_http_client.rb
222
234
  - lib/procon_bypass_man/support/remote_macro_http_client.rb
223
235
  - lib/procon_bypass_man/support/report_http_client.rb
236
+ - lib/procon_bypass_man/support/retryable.rb
224
237
  - lib/procon_bypass_man/support/safe_timeout.rb
225
238
  - lib/procon_bypass_man/support/send_device_stats_http_client.rb
226
- - lib/procon_bypass_man/support/server_pool.rb
227
239
  - lib/procon_bypass_man/support/signal_handler.rb
228
240
  - lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
229
241
  - lib/procon_bypass_man/support/uptime.rb
@@ -234,6 +246,7 @@ files:
234
246
  - lib/procon_bypass_man/websocket/client.rb
235
247
  - lib/procon_bypass_man/websocket/forever.rb
236
248
  - lib/procon_bypass_man/websocket/watchdog.rb
249
+ - lib/procon_bypass_man/worker.rb
237
250
  - procon_bypass_man.gemspec
238
251
  - project_template/README.md
239
252
  - project_template/app.rb
@@ -1,45 +0,0 @@
1
- module ProconBypassMan
2
- module Background
3
- class JobRunner
4
- MAX_QUEUE_SIZE = 100
5
-
6
- def self.start!
7
- new.start!
8
- end
9
-
10
- # for test
11
- def stop!
12
- return unless defined?(@thread)
13
- @thread.kill
14
- end
15
-
16
- def start!
17
- return if defined?(@thread)
18
- @thread = Thread.new do
19
- while(item = self.class.queue.pop)
20
- begin
21
- JobPerformer.new(klass: item[:reporter_class], args: item[:args]).perform
22
- sleep(1)
23
- rescue => e
24
- ProconBypassMan.logger.error(e)
25
- end
26
- end
27
- end
28
- self
29
- end
30
-
31
- def self.queue
32
- @@queue ||= Queue.new
33
- end
34
-
35
- def self.push(hash)
36
- if queue.size > MAX_QUEUE_SIZE
37
- ProconBypassMan.logger.error('Over queue size cap!!')
38
- return
39
- end
40
-
41
- queue.push(hash)
42
- end
43
- end
44
- end
45
- end
@@ -1,5 +0,0 @@
1
- module ProconBypassMan::HasInternalApiSetting
2
- def server_pool
3
- ProconBypassMan.config.internal_server_pool
4
- end
5
- end
@@ -1,15 +0,0 @@
1
- class ProconBypassMan::ReportPressedButtonsJob < ProconBypassMan::BaseJob
2
- extend ProconBypassMan::HasInternalApiSetting
3
-
4
- # @param [String] body
5
- def self.perform(body)
6
- ProconBypassMan::ReportHttpClient.new(
7
- path: path,
8
- server_pool: server_pool,
9
- ).post(body: body, event_type: :internal)
10
- end
11
-
12
- def self.path
13
- "/api/pressed_buttons"
14
- end
15
- end
@@ -1,43 +0,0 @@
1
- class ProconBypassMan::Bypass
2
- module UsbHidLogger
3
- include ProconBypassMan::Callbacks
4
-
5
- define_callbacks :send_gadget_to_procon
6
- define_callbacks :send_procon_to_gadget
7
-
8
- set_callback :send_gadget_to_procon, :after, :log_send_gadget_to_procon
9
- set_callback :send_procon_to_gadget, :after, :log_procon_to_gadget
10
-
11
- def log_send_gadget_to_procon
12
- return unless bypass_value.to_text
13
-
14
- if ProconBypassMan.config.verbose_bypass_log
15
- ProconBypassMan.logger.debug { ">>> #{bypass_value.to_text}" }
16
- else
17
- ProconBypassMan.cache.fetch key: 'bypass_log', expires_in: 1 do
18
- ProconBypassMan.logger.debug { ">>> #{bypass_value.to_text}" }
19
- end
20
- end
21
- end
22
-
23
- def log_procon_to_gadget
24
- return unless bypass_value.to_text
25
-
26
- if ProconBypassMan.config.verbose_bypass_log
27
- ProconBypassMan.logger.debug { "<<< #{bypass_value.to_text}" }
28
- else
29
- ProconBypassMan.cache.fetch key: 'bypass_log', expires_in: 1 do
30
- ProconBypassMan.logger.debug { "<<< #{bypass_value.to_text}" }
31
- end
32
- end
33
-
34
- if ProconBypassMan.config.enable_reporting_pressed_buttons
35
- ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
36
- ProconBypassMan::ReportPressedButtonsJob.perform_async(
37
- bypass_value.binary.to_procon_reader.to_hash
38
- )
39
- end
40
- end
41
- end
42
- end
43
- end