-
Notifications
You must be signed in to change notification settings - Fork 7
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: support streaming in node JS SDK #452
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #452 +/- ##
=======================================
Coverage 84.09% 84.09%
=======================================
Files 8 8
Lines 3936 3936
=======================================
Hits 3310 3310
Misses 626 626 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
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.
nice!
One thing that worry me is the error handling in startStreamingUpdates
. Let's say there is an network error for a minute for any reason and then a recover. What will happen to the Flipt client and how user could recover from it?
yeah good point. we should likely add some reconnect/retry logic for both streaming and polling. it would be great to be smarter about error handling in general, like if its a 401 or 404 error because of bad auth token or invalid URL then it should exit quickly with error. but if its a transient networking error then we should try to reconnect. will look into how we can support this |
Re: #430
This pull request introduces significant enhancements to the
FliptEvaluationClient
in theflipt-client-node
package, including support for both polling and streaming fetch modes, and refactors to improve code readability and maintainability. The most important changes include modifications to the client initialization, the addition of streaming support, and updates to the testing suite to accommodate these new features.Enhancements to
FliptEvaluationClient
:Client Initialization:
namespace
andfetchMode
parameters in the client constructor and initialization method. (flipt-client-node/src/index.ts
) [1] [2]flipt-client-node/src/index.ts
) [1] [2]Streaming Support:
flipt-client-node/src/index.ts
) [1] [2]StreamChunk
andStreamResult
to handle streaming data. (flipt-client-node/src/internal/models.ts
)Updates to Testing Suite:
runTests
function to support both polling and streaming fetch modes. (flipt-client-node/__tests__/evaluation.test.ts
) [1] [2] [3]flipt-client-node/__tests__/evaluation.test.ts
)Additional Changes:
IFetcherOptions
to include an optionalsignal
property for aborting requests. (flipt-client-node/src/models.ts
)fetchMode
toClientOptions
to specify whether to use polling or streaming. (flipt-client-node/src/models.ts
) [1] [2]These changes improve the flexibility and robustness of the
FliptEvaluationClient
, allowing it to better handle different use cases and environments.