Class: JetstreamBridge::Consumer::ConnectionState

Inherits:
Object
  • Object
show all
Defined in:
lib/jetstream_bridge/consumer/consumer_state.rb

Overview

Tracks reconnection attempts and health check timing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(now: Time.now) ⇒ ConnectionState

Returns a new instance of ConnectionState.

Parameters:

  • now (Time) (defaults to: Time.now)

    Initial health check timestamp



76
77
78
79
# File 'lib/jetstream_bridge/consumer/consumer_state.rb', line 76

def initialize(now: Time.now)
  @reconnect_attempts = 0
  @last_health_check = now
end

Instance Attribute Details

#last_health_checkTime (readonly)

Returns When the last health check was performed.

Returns:

  • (Time)

    When the last health check was performed



73
74
75
# File 'lib/jetstream_bridge/consumer/consumer_state.rb', line 73

def last_health_check
  @last_health_check
end

#reconnect_attemptsInteger

Returns Number of consecutive reconnection attempts.

Returns:

  • (Integer)

    Number of consecutive reconnection attempts



71
72
73
# File 'lib/jetstream_bridge/consumer/consumer_state.rb', line 71

def reconnect_attempts
  @reconnect_attempts
end

Instance Method Details

#mark_health_check(now = Time.now) ⇒ void

This method returns an undefined value.

Record that a health check was performed.

Parameters:

  • now (Time) (defaults to: Time.now)

    Timestamp of the health check



85
86
87
# File 'lib/jetstream_bridge/consumer/consumer_state.rb', line 85

def mark_health_check(now = Time.now)
  @last_health_check = now
end