Class: RSwim::Member::HealthState::Alive

Inherits:
Base
  • Object
show all
Defined in:
lib/rswim/member/health_state/alive.rb

Instance Attribute Summary

Attributes inherited from Base

#propagation_count

Instance Method Summary collapse

Methods inherited from Base

#increment_propagation_count

Constructor Details

#initialize(id, node_member_id, member_pool, must_propagate: false) ⇒ Alive

Returns a new instance of Alive.



7
8
9
10
# File 'lib/rswim/member/health_state/alive.rb', line 7

def initialize(id, node_member_id, member_pool, must_propagate: false)
  super
  @failed_to_reply = false
end

Instance Method Details

#advance(_elapsed_seconds) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rswim/member/health_state/alive.rb', line 12

def advance(_elapsed_seconds)
  if @failed_to_reply
    Suspected.new(@id, @node_member_id, @member_pool, must_propagate: true, send_ping_request: true)
  else
    self
  end
end

#can_be_pinged?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rswim/member/health_state/alive.rb', line 37

def can_be_pinged?
  true
end

#member_failed_to_replyObject



33
34
35
# File 'lib/rswim/member/health_state/alive.rb', line 33

def member_failed_to_reply
  @failed_to_reply = true
end

#statusObject



41
42
43
# File 'lib/rswim/member/health_state/alive.rb', line 41

def status
  :alive
end

#update_suspicion(status, old_incarnation_number, gossip_incarnation_number) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rswim/member/health_state/alive.rb', line 20

def update_suspicion(status, old_incarnation_number, gossip_incarnation_number)
  case status
  when :confirmed then Confirmed.new(@id, @node_member_id, @member_pool)
  when :suspected
    if gossip_incarnation_number >= old_incarnation_number
      Suspected.new(@id, @node_member_id, @member_pool, send_ping_request: false)
    else
      self
    end
  when :alive then self
  end
end