Class: Async::Container::Statistics

Inherits:
Object
  • Object
show all
Defined in:
lib/async/container/statistics.rb

Overview

Tracks various statistics relating to child instances in a container.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatistics

Returns a new instance of Statistics.



29
30
31
32
33
# File 'lib/async/container/statistics.rb', line 29

def initialize
	@spawns = 0
	@restarts = 0
	@failures = 0
end

Instance Attribute Details

#failuresObject (readonly)

How many child instances have failed.



45
46
47
# File 'lib/async/container/statistics.rb', line 45

def failures
  @failures
end

#restartsObject (readonly)

How many child instances have been restarted.



41
42
43
# File 'lib/async/container/statistics.rb', line 41

def restarts
  @restarts
end

#spawnsObject (readonly)

How many child instances have been spawned.



37
38
39
# File 'lib/async/container/statistics.rb', line 37

def spawns
  @spawns
end

Instance Method Details

#<<(other) ⇒ Object

Append another statistics instance into this one.



70
71
72
73
74
# File 'lib/async/container/statistics.rb', line 70

def << other
	@spawns += other.spawns
	@restarts += other.restarts
	@failures += other.failures
end

#failed?Boolean

Whether there have been any failures.

Returns:

  • (Boolean)


64
65
66
# File 'lib/async/container/statistics.rb', line 64

def failed?
	@failures > 0
end

#failure!Object

Increment the number of failures by 1.



58
59
60
# File 'lib/async/container/statistics.rb', line 58

def failure!
	@failures += 1
end

#restart!Object

Increment the number of restarts by 1.



53
54
55
# File 'lib/async/container/statistics.rb', line 53

def restart!
	@restarts += 1
end

#spawn!Object

Increment the number of spawns by 1.



48
49
50
# File 'lib/async/container/statistics.rb', line 48

def spawn!
	@spawns += 1
end