FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: align FDv2 goodbye event with spec (reason-only) by keelerm84 · Pull Request #422 · launchdarkly/python-server-sdk · GitHub

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

Filter by extension

Filter by extension .py  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 1 addition & 6 deletions ldclient/impl/datasourcev2/streaming.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL