Repository navigation
feat: introduce SSE (ref AI-984) #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
556ca49
feat: introduce SSE (ref AI-984)
leakonvalinka 94ce949
small fixups
leakonvalinka a41859d
remove duplicate method def
leakonvalinka aab31af
small fixes
leakonvalinka d0ab155
implement review feedback
leakonvalinka 1a2ca4f
remove windows-specific work-around
leakonvalinka f88ba07
Merge branch 'main' into feat/sse
leakonvalinka 5e8a3b8
run formatter
leakonvalinka 6066550
move stop check into condition block
leakonvalinka 88354c6
fixup: bump test harness to v1.4.0
toddbaert 4f1783d
fixup: commit CDN validators only after the body applies
toddbaert fed0b71
fixup: match Java/.NET SSE re-fetch field names
toddbaert 6387831
fixup: make a repeated initialize a no-op
toddbaert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
|---|---|---|
|
|
@@ -9,3 +9,7 @@ coverage.xml | |
| .mypy_cache/ | ||
| .ruff_cache/ | ||
| .pytest_cache/ | ||
| .idea/ | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
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
Submodule fm-provider-test-harness
updated
18 files
| +2 −2 | .github/workflows/mockserver-build.yml | |
| +4 −4 | .github/workflows/release-please.yml | |
| +1 −1 | .release-please-manifest.json | |
| +28 −0 | CHANGELOG.md | |
| +4 −1 | README.md | |
| +1 −1 | docker-compose.yaml | |
| +8 −0 | flags/flags-v1-sse.json | |
| +8 −0 | flags/flags-v2-sse.json | |
| +3 −3 | gherkin/cdn.feature | |
| +221 −0 | gherkin/sse.feature | |
| +4 −0 | gherkin/timings.json | |
| +3 −3 | mockserver/README.md | |
| +47 −7 | mockserver/control_api.go | |
| +22 −2 | mockserver/mock_api.go | |
| +2 −0 | mockserver/server.go | |
| +196 −3 | mockserver/server_test.go | |
| +70 −5 | mockserver/state.go | |
| +1 −1 | version.txt |
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
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
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import typing | ||
|
|
||
| #: ``eventStreams[].type`` value identifying the SSE change-notification stream | ||
| STREAM_TYPE_SSE = "sse" | ||
|
|
||
|
|
||
| def _non_blank(value: typing.Any) -> str | None: | ||
| return value if isinstance(value, str) and value.strip() else None | ||
|
|
||
|
|
||
| def extract_sse_url(config_json: str | None, fallback_origin: str | None) -> str | None: | ||
| """Return the SSE URL of the first ``sse`` entry in ``eventStreams``. | ||
| A non-blank ``url`` wins; else ``endpoint.requestUri`` on ``endpoint.origin`` or ``fallback_origin``.""" | ||
| if not config_json or not config_json.strip(): | ||
| return None | ||
| try: | ||
| config: typing.Any = json.loads(config_json) | ||
| except ValueError: | ||
| return None | ||
| streams = config.get("eventStreams") if isinstance(config, dict) else None | ||
| if not isinstance(streams, list): | ||
| return None | ||
| for stream in streams: | ||
| if not isinstance(stream, dict) or stream.get("type") != STREAM_TYPE_SSE: | ||
| continue | ||
| url = _non_blank(stream.get("url")) | ||
| if url is not None: | ||
| return url | ||
| endpoint = stream.get("endpoint") | ||
| if not isinstance(endpoint, dict): | ||
| return None | ||
| request_uri = _non_blank(endpoint.get("requestUri")) | ||
| if request_uri is None: | ||
| return None | ||
| origin = _non_blank(endpoint.get("origin")) or _non_blank(fallback_origin) | ||
| return origin + request_uri if origin is not None else None | ||
| return None |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A repeated
initialize()is now a no-op (6387831), so there's no second fetch to race with the running poller. Tracked across providers in AI-1639.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shutdown + re-initialize variant from the latest review is real but narrow (a poll has to finish between its stop check and its apply while the lifecycle is replaced). Same gap exists in all our providers, so we'll fix it consistently there: poll callbacks name the poller they came from and the provider drops them unless it's still current, like the SSE callbacks. Tracked in AI-1639.