Class DefaultEventSender

  • All Implemented Interfaces:
    EventSender, java.io.Closeable, java.lang.AutoCloseable

    public final class DefaultEventSender
    extends java.lang.Object
    implements EventSender
    The default implementation of delivering JSON data to an LaunchDarkly event endpoint. This is the only implementation that is used by the SDKs. It is abstracted out with an interface for the sake of testability.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultEventSender​(HttpProperties httpProperties, java.lang.String analyticsRequestPath, java.lang.String diagnosticRequestPath, long retryDelayMillis, com.launchdarkly.logging.LDLogger logger)
      Creates an instance.
    • Field Detail

      • DEFAULT_RETRY_DELAY_MILLIS

        public static final long DEFAULT_RETRY_DELAY_MILLIS
        Default value for retryDelayMillis parameter.
        See Also:
        Constant Field Values
      • DEFAULT_ANALYTICS_REQUEST_PATH

        public static final java.lang.String DEFAULT_ANALYTICS_REQUEST_PATH
        Default value for analyticsRequestPath parameter, for the server-side SDK. The Android SDK should modify this value.
        See Also:
        Constant Field Values
      • DEFAULT_DIAGNOSTIC_REQUEST_PATH

        public static final java.lang.String DEFAULT_DIAGNOSTIC_REQUEST_PATH
        Default value for diagnosticRequestPath parameter, for the server-side SDK. The Android SDK should modify this value.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultEventSender

        public DefaultEventSender​(HttpProperties httpProperties,
                                  java.lang.String analyticsRequestPath,
                                  java.lang.String diagnosticRequestPath,
                                  long retryDelayMillis,
                                  com.launchdarkly.logging.LDLogger logger)
        Creates an instance.
        Parameters:
        httpProperties - the HTTP configuration
        analyticsRequestPath - the request path for posting analytics events
        diagnosticRequestPath - the request path for posting diagnostic events
        retryDelayMillis - retry delay, or zero to use the default
        logger - the logger
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • sendAnalyticsEvents

        public EventSender.Result sendAnalyticsEvents​(byte[] data,
                                                      int eventCount,
                                                      java.net.URI eventsBaseUri)
        Description copied from interface: EventSender
        Attempt to deliver an analytics event data payload.

        This method will be called synchronously from an event delivery worker thread.

        Specified by:
        sendAnalyticsEvents in interface EventSender
        Parameters:
        data - the preformatted JSON data, in UTF-8 encoding
        eventCount - the number of individual events in the data
        eventsBaseUri - the configured events endpoint base URI
        Returns:
        a EventSender.Result
      • sendDiagnosticEvent

        public EventSender.Result sendDiagnosticEvent​(byte[] data,
                                                      java.net.URI eventsBaseUri)
        Description copied from interface: EventSender
        Attempt to deliver a diagnostic event data payload.

        This method will be called synchronously from an event delivery worker thread.

        Specified by:
        sendDiagnosticEvent in interface EventSender
        Parameters:
        data - the preformatted JSON data, as a string
        eventsBaseUri - the configured events endpoint base URI
        Returns:
        a EventSender.Result