4.0.0
LaunchDarklyReleaseBot
released this
20 Dec 01:04
·
9 commits
to main
since this release
[4.0.0] - 2022-12-19
This release revises the implementation of EventSource
so that it does not create its own worker threads. The methods for starting and reading a stream now perform synchronous I/O, and the caller is responsible for choosing what thread to start the stream and read the stream on. This makes the core implementation simpler and more efficient, and reduces possibilities for deadlock. If you want to continue using the old asynchronous push model, see the com.launchdarkly.eventsource.background
package.
The configuration API has also been revised to separate out the HTTP functionality and the backoff/retry logic into subcomponents which can be customized or replaced.
Added:
EventSource
methodsreadMessage()
,readAnyEvents()
,messages()
, andanyEvents()
for synchronously reading events.EventSource.Builder(ConnectStrategy)
constructor and theConnectStrategy
andHttpConnectStrategy
classes, for customizing connection parameters.EventSource.Builder(URI)
,(URL)
, and(HttpUrl)
constructors, as shortcuts for minimal HTTP configuration.EventSource.Builder.errorStrategy
and theErrorStrategy
class, for customizing error recovery behavior.EventSource.Builder.retryDelayStrategy
and theRetryDelayStrategy
andDefaultRetryDelayStrategy
classes, for customizing or replacing backoff/jitter behavior.StreamEvent
,CommentEvent
,StartedEvent
, andFaultEvent
classes, representing types of information other thanMessageEvent
that you can read synchronously from the stream.- The
com.launchdarkly.eventsource.background
package, containing theBackgroundEventSource
wrapper for emulating the old push model.
Changed:
EventSource.Builder.restart
is renamed tointerrupt
, to clarify that the restarting of the stream is not done immediately but only happens if you continue trying to read events afterinterrupt()
.EventSource.Builder.backoffResetThreshold
is renamed toretryDelayResetThreshold
, to clarify that it applies to whatever kind ofRetryDelayStrategy
is being used even if that is not the default backoff strategy.EventSource.Builder.reconnectTime
is renamed toretryDelay
, to clarify that it is describing a duration rather than a moment in time.UnsuccessfulResponseException
is renamed toStreamHttpErrorException
, to clarify that it is specifically referring to an HTTP response with an error status.- The implementation of
streamEventData
mode is now simpler and no longer usesPipedInputStream
andPipedOutputStream
internally.
Removed:
ConnectionHandler
andEventSource.Builder.connectionHandler()
: replaced byErrorStrategy
.EventHandler
and theEventSource.Builder(URI, EventHandler)
constructor: replaced byBackgroundEventHandler
if you are usingBackgroundEventSource
.EventSource.Builder
methodsconnectTimeout
,readTimeout
,writeTimeout
,method
,body
,headers
,proxy
,proxyAuthenticator
, andrequestTransformer
: replaced by methods inHttpConnectStrategy
.EventSource.Builder.maxReconnect
: replaced byDefaultRetryDelayStrategy.maxDelay
.EventSource.Builder.maxEventTasksInFlight
: replaced by an equivalent option inBackgroundEventSource
.