-
Notifications
You must be signed in to change notification settings - Fork 60
Feat/streaming #201
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
Feat/streaming #201
Conversation
db928fb to
a3bb209
Compare
streaming_integration_test.go
Outdated
| assert.False(t, client.IsEnabled("feature-1"), "feature-1 should be initially disabled") | ||
|
|
||
| // Wait for the update event to be processed | ||
| time.Sleep(200 * time.Millisecond) |
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.
listen to update event
streaming_client.go
Outdated
| return nil | ||
| } | ||
|
|
||
| log.Print("Setting up client") |
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.
leftover
config.go
Outdated
| backupPath string | ||
| refreshInterval time.Duration | ||
| storage Storage | ||
| httpClient *http.Client |
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.
weird formatting
repository.go
Outdated
| if repo.isStreaming { | ||
| repo.streamingClient = newStreamingClient( | ||
| options, | ||
| repo, |
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.
this is weird that repository created a streaming client and passes itself as argument
| // deltaProcessor handles processing of delta events and updating the feature storage | ||
| type deltaProcessor struct { | ||
| storage Storage | ||
| repository *repository // Repository reference for segment manipulation |
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.
can it depend on some inverted dependency being the operation that will be called. because now we have a cyclical dependency where repository creates delta processor and processor calls repository creating a cycle.
| r.segments = segments | ||
|
|
||
| // Update storage | ||
| return r.options.storage.Reset(features, true) |
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.
some claude analysis told me it may lead to race conditions with isEnabled calls but haven't dug deeper
Summary
This PR introduces experimental streaming mode support to the
Unleash Go SDK, enabling real-time feature flag updates through
Server-Sent Events (SSE) instead of traditional polling. The
implementation provides instant updates when feature flags change
on the server.
Key Features
for instant feature flag changes
streaming is unavailable
using hydration and delta events
to work without changes
recovery
Architecture Changes
New Components
and event processing
events and manages feature state
updates including:
Key Implementation Details
connections
state
separation
processing, eliminating redundant full-response logic
Configuration
Enable streaming mode by setting the experimental streaming
configuration:
unleash.Initialize(
unleash.WithUrl("https://your-unleash-instance.com/api/"),
unleash.WithAppName("my-app"),
unleash.WithExperimental(map[string]interface{}{
"type": "streaming",
}),
)
Testing
work
Files Changed
support