fast_ci 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76c1186cf1228f3465acc2228203c51070ac0c80c18f567dec89d7bdcacca0c2
4
- data.tar.gz: 15ab92271b656e5020a52f8b98fb1d53f587d7626f3c6035aa426b0cf57707f7
3
+ metadata.gz: b81a68573c2f4000217c3783c48815e591f3b143ca185d6e379a0f7d27e1ac6e
4
+ data.tar.gz: e5d8b616c8739f83f48dd47e20db300a434161c9bea4a71ce9411802f537ef8d
5
5
  SHA512:
6
- metadata.gz: bab65efe177bb36d558cd3d50977b11cf2422aed04c70791bac94b1f62d5e533099e7cdf0d3123363da31cbed50c57b472b23e00d67a6b3c474b03999d2fc4b3
7
- data.tar.gz: db5e94d7764901155fe12199da461dfd7da3a72155de0a1f918f07fe8897202b6c55e3a92b62e08560e1b462979fc8b4c7842bd3f539f7cf012134506ce9a50e
6
+ metadata.gz: fe3f867a2d7b7045ed9948d2779c5c7940414f5f2c724f992c97bcd368c31f8ead8f6c4e9da5d34fcbd274268aaeb6778aa582853c3ee386e9db54f8a62a745e
7
+ data.tar.gz: d8786cabc21ceddbee5826ce36dd874f0bcbbe4ff3f075b095a1bf3db693cc1d414d840474916822843ec59ab6b3c2c53ccd43f9a4d07564cd437addef899ae2
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- fast_ci (1.2.0)
14
+ fast_ci (1.2.1)
15
15
  async-websocket (<= 0.20.0)
16
16
  brakeman (>= 5.4.1)
17
17
  console (>= 1.10.0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastCI
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
data/lib/fast_ci.rb CHANGED
@@ -113,7 +113,7 @@ module FastCI
113
113
 
114
114
  def initialize(run_key)
115
115
  @on = {}
116
- @ref = 0
116
+ @ref = 1
117
117
  @run_key = run_key
118
118
  end
119
119
 
@@ -124,20 +124,24 @@ module FastCI
124
124
  @on[event] = block
125
125
  end
126
126
 
127
- def send_msg(event, payload = {}, custom_topic = nil)
127
+ def send_msg(event, payload = {}, custom_topic = nil, custom_ref = nil)
128
128
  FastCI.debug("ws#send_msg: #{event} -> #{payload.inspect}")
129
- connection.write({ "topic": custom_topic || topic, "event": event, "payload": payload, "ref": ref })
129
+ connection.write({ "topic": custom_topic || topic, "event": event, "payload": payload, "ref": custom_ref || ref })
130
130
  connection.flush
131
131
  end
132
132
 
133
+ def get_connection
134
+ connection
135
+ end
136
+
133
137
  def connect_to_ws
134
138
  Async do |task|
135
139
  before_start_connection
136
140
 
137
141
  begin
138
142
  Async::WebSocket::Client.connect(endpoint) do |connection|
139
- after_start_connection
140
143
  self.connection = connection
144
+ after_start_connection
141
145
  self.task = task
142
146
  yield
143
147
 
@@ -163,6 +167,7 @@ module FastCI
163
167
  Async do
164
168
  loop do
165
169
  sleep 30
170
+ break if connection.closed?
166
171
  send_heartbeat
167
172
  end
168
173
  end
@@ -170,7 +175,7 @@ module FastCI
170
175
 
171
176
  def send_heartbeat
172
177
  FastCI.debug("Sending heartbeat")
173
- send_msg("heartbeat", {}, "phoenix")
178
+ send_msg("heartbeat", {}, "phoenix", 0)
174
179
  end
175
180
 
176
181
  def await(retry_count = 0)
@@ -182,6 +187,9 @@ module FastCI
182
187
  FastCI.debug("ws#msg_received: #{message.inspect}")
183
188
 
184
189
  response = message.dig(:payload, :response)
190
+
191
+ # Heartbeat
192
+ next if message.dig(:ref) == 0
185
193
 
186
194
  case response&.dig(:event) || message[:event]
187
195
  when "phx_error"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nesha Zoric
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-08 00:00:00.000000000 Z
11
+ date: 2025-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console