Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions ldclient/impl/datasourcev2/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,7 @@ def _process_message(

if msg.event == EventName.GOODBYE:
goodbye = Goodbye.from_dict(json.loads(msg.data))
if not goodbye.silent:
log.error(
"SSE server received error: %s (%s)",
goodbye.reason,
goodbye.catastrophe,
)
log.info("SSE server sent goodbye: %s", goodbye.reason)

return None

Expand Down
10 changes: 2 additions & 8 deletions ldclient/impl/datasystem/protocolv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,13 @@ class Goodbye:
"""

reason: str
silent: bool
catastrophe: bool

def to_dict(self) -> dict:
"""
Serializes the Goodbye to a JSON-compatible dictionary.
"""
return {
"reason": self.reason,
"silent": self.silent,
"catastrophe": self.catastrophe,
}

@staticmethod
Expand All @@ -139,13 +135,11 @@ def from_dict(data: dict) -> "Goodbye":
Deserializes a Goodbye event from a JSON-compatible dictionary.
"""
reason = data.get("reason")
silent = data.get("silent")
catastrophe = data.get("catastrophe")

if reason is None or silent is None or catastrophe is None:
if reason is None:
raise ValueError("Missing required fields in Goodbye JSON.")

return Goodbye(reason=reason, silent=silent, catastrophe=catastrophe)
return Goodbye(reason=reason)


@dataclass(frozen=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def events() -> dict:
data=json.dumps(selector.to_dict()),
)

goodbye = Goodbye(reason="test reason", silent=True, catastrophe=False)
goodbye = Goodbye(reason="test reason")
goodbye_event = Event(
event=EventName.GOODBYE,
data=json.dumps(goodbye.to_dict()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def events() -> dict:
data=json.dumps(selector.to_dict()),
)

goodbye = Goodbye(reason="test reason", silent=True, catastrophe=False)
goodbye = Goodbye(reason="test reason")
goodbye_event = Event(
event=EventName.GOODBYE,
data=json.dumps(goodbye.to_dict()),
Expand Down
Loading