Class: Soba::Services::IssueWatcher
- Inherits:
-
Object
- Object
- Soba::Services::IssueWatcher
- Includes:
- SemanticLogger::Loggable
- Defined in:
- lib/soba/services/issue_watcher.rb
Constant Summary collapse
- MIN_INTERVAL =
10
Instance Method Summary collapse
- #fetch_issues(state: "open") ⇒ Object
-
#initialize(client: nil, repository: nil, interval: nil) ⇒ IssueWatcher
constructor
A new instance of IssueWatcher.
- #running? ⇒ Boolean
- #start(repository:, interval: 20) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(client: nil, repository: nil, interval: nil) ⇒ IssueWatcher
Returns a new instance of IssueWatcher.
13 14 15 16 17 18 19 20 |
# File 'lib/soba/services/issue_watcher.rb', line 13 def initialize(client: nil, repository: nil, interval: nil) @github_client = client || Infrastructure::GitHubClient.new @repository = repository @interval = interval @running = Concurrent::AtomicBoolean.new(false) @mutex = Mutex.new @signal_received = false end |
Instance Method Details
#fetch_issues(state: "open") ⇒ Object
54 55 56 |
# File 'lib/soba/services/issue_watcher.rb', line 54 def fetch_issues(state: "open") @github_client.issues(@repository, state: state) end |
#running? ⇒ Boolean
50 51 52 |
# File 'lib/soba/services/issue_watcher.rb', line 50 def running? @running.value end |
#start(repository:, interval: 20) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/soba/services/issue_watcher.rb', line 22 def start(repository:, interval: 20) validate_interval!(interval) logger.info "Starting issue watcher", repository: repository, interval: interval @running.make_true @repository = repository @interval = interval setup_signal_handlers display_header execution_count = run_monitoring_loop # Show graceful shutdown message if @signal_received puts "\n✅ Issue watcher stopped gracefully (#{execution_count} executions)" else puts "\n✅ Issue watcher stopped successfully (#{execution_count} executions)" logger.info "Issue watcher stopped", executions: execution_count end ensure @running.make_false end |
#stop ⇒ Object
46 47 48 |
# File 'lib/soba/services/issue_watcher.rb', line 46 def stop @running.make_false end |