Skip to content

Commit

Permalink
Server-Sent Events (SSE) support (#36)
Browse files Browse the repository at this point in the history
* WIP realtime features repo

* add SSE config to existing GBFeaturesRepository

* interceptor notes

* fix real networking test

* WIP: event stream connection

* add error for SSE

* add constructor w/o okHttpClient

* no timeout for SSE connections

* add test server to test SSE refreshing

* implement retry functionality

* fallback to SWR refresh strategy

* refactor: separate method to process response JSON string

* update features json from SSE payload

* remove custom http client from the builder class

* rm log statements

* bump version to 0.9.0
  • Loading branch information
tinahollygb committed Aug 1, 2023
1 parent 97ca6ab commit 8dae94d
Show file tree
Hide file tree
Showing 9 changed files with 384 additions and 93 deletions.
4 changes: 3 additions & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ dependencies {
implementation 'com.google.code.gson:gson:2.9.1'

// https://square.github.io/okhttp
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-sse
implementation 'com.squareup.okhttp3:okhttp-sse:4.11.0'

// Adds getter, setter and builder boilerplate
// https://projectlombok.org/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public enum FeatureFetchErrorCode {
*/
NO_RESPONSE_ERROR,

/**
* - could not establish a connection to the events (server-sent events) for feature updates
*/
SSE_CONNECTION_ERROR,

/**
* - there was an unknown error that occurred when attempting to make the request.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package growthbook.sdk.java;

public enum FeatureRefreshStrategy {
STALE_WHILE_REVALIDATE,
SERVER_SENT_EVENTS
}
Loading

0 comments on commit 8dae94d

Please sign in to comment.