A Ruby gem for streaming data from the Bluesky/ATProto firehose

rolled back the heartbeat timer for now

This reverts commit 5d485ae61eccc16a138c509c3a4d643b7586e6b0.

# Conflicts:
# lib/skyfall/stream.rb

+2 -22
+2 -22
lib/skyfall/stream.rb
··· 14 :subscribe_labels => SUBSCRIBE_LABELS 15 } 16 17 - EVENTS = %w(message raw_message connecting connect disconnect reconnect error timeout) 18 19 MAX_RECONNECT_INTERVAL = 300 20 21 - attr_accessor :heartbeat_timeout, :heartbeat_interval, :cursor, :auto_reconnect, :last_update 22 23 def initialize(server, endpoint, cursor = nil) 24 @endpoint = check_endpoint(endpoint) ··· 27 @handlers = {} 28 @auto_reconnect = true 29 @connection_attempts = 0 30 - @heartbeat_interval = 10 31 - @heartbeat_timeout = 300 32 - @last_update = nil 33 34 @handlers[:error] = proc { |e| puts "ERROR: #{e}" } 35 end ··· 54 55 @ws.on(:open) do |e| 56 @handlers[:connect]&.call 57 - @last_update = Time.now 58 - start_heartbeat_timer 59 end 60 61 @ws.on(:message) do |msg| 62 @reconnecting = false 63 @connection_attempts = 0 64 - @last_update = Time.now 65 66 data = msg.data.pack('C*') 67 @handlers[:raw_message]&.call(data) ··· 115 end 116 117 alias close disconnect 118 - 119 - def start_heartbeat_timer 120 - return if @timer || @heartbeat_interval.to_f <= 0 || @heartbeat_timeout.to_f <= 0 121 - 122 - @timer = EM::PeriodicTimer.new(@heartbeat_interval) do 123 - next if @ws.nil? || @heartbeat_timeout.to_f <= 0 124 - time_passed = Time.now - @last_update 125 - 126 - if time_passed > @heartbeat_timeout 127 - @handlers[:timeout]&.call 128 - reconnect 129 - end 130 - end 131 - end 132 133 EVENTS.each do |event| 134 define_method "on_#{event}" do |&block|
··· 14 :subscribe_labels => SUBSCRIBE_LABELS 15 } 16 17 + EVENTS = %w(message raw_message connecting connect disconnect reconnect error) 18 19 MAX_RECONNECT_INTERVAL = 300 20 21 + attr_accessor :heartbeat_timeout, :heartbeat_interval, :cursor, :auto_reconnect 22 23 def initialize(server, endpoint, cursor = nil) 24 @endpoint = check_endpoint(endpoint) ··· 27 @handlers = {} 28 @auto_reconnect = true 29 @connection_attempts = 0 30 31 @handlers[:error] = proc { |e| puts "ERROR: #{e}" } 32 end ··· 51 52 @ws.on(:open) do |e| 53 @handlers[:connect]&.call 54 end 55 56 @ws.on(:message) do |msg| 57 @reconnecting = false 58 @connection_attempts = 0 59 60 data = msg.data.pack('C*') 61 @handlers[:raw_message]&.call(data) ··· 109 end 110 111 alias close disconnect 112 113 EVENTS.each do |event| 114 define_method "on_#{event}" do |&block|