4.0.0
·
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:
EventSourcemethodsreadMessage(),readAnyEvents(),messages(), andanyEvents()for synchronously reading events.EventSource.Builder(ConnectStrategy)constructor and theConnectStrategyandHttpConnectStrategyclasses, for customizing connection parameters.EventSource.Builder(URI),(URL), and(HttpUrl)constructors, as shortcuts for minimal HTTP configuration.EventSource.Builder.errorStrategyand theErrorStrategyclass, for customizing error recovery behavior.EventSource.Builder.retryDelayStrategyand theRetryDelayStrategyandDefaultRetryDelayStrategyclasses, for customizing or replacing backoff/jitter behavior.StreamEvent,CommentEvent,StartedEvent, andFaultEventclasses, representing types of information other thanMessageEventthat you can read synchronously from the stream.- The
com.launchdarkly.eventsource.backgroundpackage, containing theBackgroundEventSourcewrapper for emulating the old push model.
Changed:
EventSource.Builder.restartis 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.backoffResetThresholdis renamed toretryDelayResetThreshold, to clarify that it applies to whatever kind ofRetryDelayStrategyis being used even if that is not the default backoff strategy.EventSource.Builder.reconnectTimeis renamed toretryDelay, to clarify that it is describing a duration rather than a moment in time.UnsuccessfulResponseExceptionis renamed toStreamHttpErrorException, to clarify that it is specifically referring to an HTTP response with an error status.- The implementation of
streamEventDatamode is now simpler and no longer usesPipedInputStreamandPipedOutputStreaminternally.
Removed:
ConnectionHandlerandEventSource.Builder.connectionHandler(): replaced byErrorStrategy.EventHandlerand theEventSource.Builder(URI, EventHandler)constructor: replaced byBackgroundEventHandlerif you are usingBackgroundEventSource.EventSource.BuildermethodsconnectTimeout,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.