Skip to content

Commit

Permalink
πŸ’‡β€β™€οΈ
Browse files Browse the repository at this point in the history
  • Loading branch information
robertomiranda committed Aug 15, 2024
1 parent 54f74be commit 60affe2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/promenade/periodic_stats.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'singleton'
require "singleton"

module Promenade
class PeriodicStats
Expand Down Expand Up @@ -32,7 +32,7 @@ def start

@thread_stopped = false
@thread = Thread.new do
while active? do
while active?
block.call
sleep(frequency) # Ensure the sleep is inside the loop
end
Expand All @@ -55,14 +55,14 @@ def stop

private

attr_reader :logger, :frequency, :block, :thread, :thread_stopped
attr_reader :logger, :frequency, :block, :thread, :thread_stopped

def started?
thread&.alive?
end
def started?
thread&.alive?
end

def active?
!thread_stopped
end
def active?
!thread_stopped
end
end
end
4 changes: 2 additions & 2 deletions lib/promenade/pitchfork/stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def self.instrument
attr_reader :workers_count, :live_workers_count, :active_workers, :queued_requests

def capacity
return 0 if live_workers_count.nil? || live_workers_count.zero?
return 0 if live_workers_count.nil? || live_workers_count == 0

live_workers_count - active_workers
end

def busy_percent
return 0 if live_workers_count.zero?
return 0 if live_workers_count == 0

(active_workers.to_f / live_workers_count) * 100
end
Expand Down
1 change: 0 additions & 1 deletion lib/promenade/raindrops/stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Raindrops
end

class Stats

attr_reader :active_workers, :queued_requests, :listener_address

def initialize(listener_address: nil)
Expand Down
1 change: 0 additions & 1 deletion spec/promenade/pitchfork/stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@
end
end
end

0 comments on commit 60affe2

Please sign in to comment.