Skip to content

Commit 4f5a396

Browse files
authored
fix: parse FDv2 goodbye events with only a reason field (#380)
1 parent 80b8e4e commit 4f5a396

3 files changed

Lines changed: 5 additions & 23 deletions

File tree

lib/ldclient-rb/impl/data_system/protocolv2.rb

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,11 @@ class Goodbye
160160
# @return [String] The reason for goodbye
161161
attr_reader :reason
162162

163-
# @return [Boolean] Whether the goodbye is silent
164-
attr_reader :silent
165-
166-
# @return [Boolean] Whether this represents a catastrophic failure
167-
attr_reader :catastrophe
168-
169163
#
170164
# @param reason [String] The reason for goodbye
171-
# @param silent [Boolean] Whether the goodbye is silent
172-
# @param catastrophe [Boolean] Whether this represents a catastrophic failure
173165
#
174-
def initialize(reason:, silent:, catastrophe:)
166+
def initialize(reason:)
175167
@reason = reason
176-
@silent = silent
177-
@catastrophe = catastrophe
178168
end
179169

180170
#
@@ -185,8 +175,6 @@ def initialize(reason:, silent:, catastrophe:)
185175
def to_h
186176
{
187177
reason: @reason,
188-
silent: @silent,
189-
catastrophe: @catastrophe,
190178
}
191179
end
192180

@@ -199,12 +187,10 @@ def to_h
199187
#
200188
def self.from_h(data)
201189
reason = data[:reason]
202-
silent = data[:silent]
203-
catastrophe = data[:catastrophe]
204190

205-
raise ArgumentError, "Missing required fields in Goodbye" if reason.nil? || silent.nil? || catastrophe.nil?
191+
raise ArgumentError, "Missing required fields in Goodbye" if reason.nil?
206192

207-
new(reason: reason, silent: silent, catastrophe: catastrophe)
193+
new(reason: reason)
208194
end
209195
end
210196

lib/ldclient-rb/impl/data_system/streaming.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ def stop
231231

232232
when LaunchDarkly::Interfaces::DataSystem::EventName::GOODBYE
233233
goodbye = LaunchDarkly::Impl::DataSystem::ProtocolV2::Goodbye.from_h(JSON.parse(message.data, symbolize_names: true))
234-
unless goodbye.silent
235-
@logger.error { "[LDClient] SSE server received error: #{goodbye.reason} (catastrophe: #{goodbye.catastrophe})" }
236-
end
234+
@logger.info { "[LDClient] SSE server received goodbye: #{goodbye.reason}" }
237235
nil
238236

239237
when LaunchDarkly::Interfaces::DataSystem::EventName::ERROR

spec/impl/data_system/streaming_synchronizer_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ def initialize(type, data = nil)
224224
)
225225
)
226226
goodbye = LaunchDarkly::Impl::DataSystem::ProtocolV2::Goodbye.new(
227-
reason: "test reason",
228-
silent: true,
229-
catastrophe: false
227+
reason: "test reason"
230228
)
231229
selector = LaunchDarkly::Interfaces::DataSystem::Selector.new(state: "p:SOMETHING:300", version: 300)
232230

0 commit comments

Comments
 (0)