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.



12
13
14
15
16
# File 'lib/async/container/statistics.rb', line 12

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

Instance Attribute Details

#failuresObject (readonly)

How many child instances have failed.



28
29
30
# File 'lib/async/container/statistics.rb', line 28

def failures
  @failures
end

#restartsObject (readonly)

How many child instances have been restarted.



24
25
26
# File 'lib/async/container/statistics.rb', line 24

def restarts
  @restarts
end

#spawnsObject (readonly)

How many child instances have been spawned.



20
21
22
# File 'lib/async/container/statistics.rb', line 20

def spawns
  @spawns
end

Instance Method Details

#<<(other) ⇒ Object

Append another statistics instance into this one.



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

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

#failed?Boolean

Whether there have been any failures.

Returns:

  • (Boolean)


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

def failed?
	@failures > 0
end

#failure!Object

Increment the number of failures by 1.



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

def failure!
	@failures += 1
end

#restart!Object

Increment the number of restarts by 1.



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

def restart!
	@restarts += 1
end

#spawn!Object

Increment the number of spawns by 1.



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

def spawn!
	@spawns += 1
end