Class ServiceEndpointsBuilder


  • public abstract class ServiceEndpointsBuilder
    extends java.lang.Object
    Contains methods for configuring the SDK's service URIs.

    If you want to set non-default values for any of these properties, create a builder with Components.serviceEndpoints(), change its properties with the methods of this class, and pass it to LDConfig.Builder.serviceEndpoints(ServiceEndpointsBuilder).

    The default behavior, if you do not change any of these properties, is that the SDK will connect to the standard endpoints in the LaunchDarkly production service. There are several use cases for changing these properties:

    • You are using the LaunchDarkly Relay Proxy. In this case, set relayProxy(URI).
    • You are connecting to a private instance of LaunchDarkly, rather than the standard production services. In this case, there will be custom base URIs for each service, so you must set streaming(URI), polling(URI), and events(URI).
    • You are connecting to a test fixture that simulates the service endpoints. In this case, you may set the base URIs to whatever you want, although the SDK will still set the URI paths to the expected paths for LaunchDarkly services.

    Each of the setter methods can be called with either a URI or an equivalent string. Passing a string that is not a valid URI will cause an immediate IllegalArgumentException.

    If you are using a private instance and you set some of the base URIs, but not all of them, the SDK will log an error and may not work properly. The only exception is if you have explicitly disabled the SDK's use of one of the services: for instance, if you have disabled analytics events with Components.noEvents(), you do not have to set events(URI).

    
         // Example of specifying a Relay Proxy instance
         LDConfig config = new LDConfig.Builder()
             .serviceEndpoints(
                 Components.serviceEndpoints()
                     .relayProxy("http://my-relay-hostname:80")
             )
             .build();
     
         // Example of specifying a private LaunchDarkly instance
         LDConfig config = new LDConfig.Builder()
             .serviceEndpoints(
                 Components.serviceEndpoints()
                     .streaming("https://stream.mycompany.launchdarkly.com")
                     .polling("https://app.mycompany.launchdarkly.com")
                     .events("https://events.mycompany.launchdarkly.com"))
             )
             .build();
     
    Since:
    5.9.0
    • Field Detail

      • streamingBaseUri

        protected java.net.URI streamingBaseUri
      • pollingBaseUri

        protected java.net.URI pollingBaseUri
      • eventsBaseUri

        protected java.net.URI eventsBaseUri
    • Constructor Detail

      • ServiceEndpointsBuilder

        public ServiceEndpointsBuilder()
    • Method Detail

      • events

        public ServiceEndpointsBuilder events​(java.net.URI eventsBaseUri)
        Sets a custom base URI for the events service.

        You should only call this method if you are using a private instance or test fixture (see ServiceEndpointsBuilder). If you are using the LaunchDarkly Relay Proxy, call relayProxy(URI) instead.

        
             LDConfig config = new LDConfig.Builder()
               .serviceEndpoints(
                   Components.serviceEndpoints()
                       .streaming("https://stream.mycompany.launchdarkly.com")
                       .polling("https://app.mycompany.launchdarkly.com")
                       .events("https://events.mycompany.launchdarkly.com")
               )
               .build();
         
        Parameters:
        eventsBaseUri - the base URI of the events service; null to use the default
        Returns:
        the builder
      • events

        public ServiceEndpointsBuilder events​(java.lang.String eventsBaseUri)
        Equivalent to events(URI), specifying the URI as a string.
        Parameters:
        eventsBaseUri - the base URI of the events service; null to use the default
        Returns:
        the builder
      • polling

        public ServiceEndpointsBuilder polling​(java.net.URI pollingBaseUri)
        Sets a custom base URI for the polling service.

        You should only call this method if you are using a private instance or test fixture (see ServiceEndpointsBuilder). If you are using the LaunchDarkly Relay Proxy, call relayProxy(URI) instead.

        
             LDConfig config = new LDConfig.Builder()
               .serviceEndpoints(
                   Components.serviceEndpoints()
                       .streaming("https://stream.mycompany.launchdarkly.com")
                       .polling("https://app.mycompany.launchdarkly.com")
                       .events("https://events.mycompany.launchdarkly.com")
               )
               .build();
         
        Parameters:
        pollingBaseUri - the base URI of the polling service; null to use the default
        Returns:
        the builder
      • polling

        public ServiceEndpointsBuilder polling​(java.lang.String pollingBaseUri)
        Equivalent to polling(URI), specifying the URI as a string.
        Parameters:
        pollingBaseUri - the base URI of the events service; null to use the default
        Returns:
        the builder
      • relayProxy

        public ServiceEndpointsBuilder relayProxy​(java.net.URI relayProxyBaseUri)
        Specifies a single base URI for a Relay Proxy instance.

        When using the LaunchDarkly Relay Proxy, the SDK only needs to know the single base URI of the Relay Proxy, which will provide all the proxied service endpoints.

        
             LDConfig config = new LDConfig.Builder()
               .serviceEndpoints(
                   Components.serviceEndpoints()
                       .relayProxy("http://my-relay-hostname:8080")
               )
               .build();
         
        Parameters:
        relayProxyBaseUri - the Relay Proxy base URI, or null to reset to default endpoints
        Returns:
        the builder
      • relayProxy

        public ServiceEndpointsBuilder relayProxy​(java.lang.String relayProxyBaseUri)
        Equivalent to relayProxy(URI), specifying the URI as a string.
        Parameters:
        relayProxyBaseUri - the Relay Proxy base URI, or null to reset to default endpoints
        Returns:
        the builder
      • streaming

        public ServiceEndpointsBuilder streaming​(java.net.URI streamingBaseUri)
        Sets a custom base URI for the streaming service.

        You should only call this method if you are using a private instance or test fixture (see ServiceEndpointsBuilder). If you are using the LaunchDarkly Relay Proxy, call relayProxy(URI) instead.

        
             LDConfig config = new LDConfig.Builder()
               .serviceEndpoints(
                   Components.serviceEndpoints()
                       .streaming("https://stream.mycompany.launchdarkly.com")
                       .polling("https://app.mycompany.launchdarkly.com")
                       .events("https://events.mycompany.launchdarkly.com")
               )
               .build();
         
        Parameters:
        streamingBaseUri - the base URI of the streaming service; null to use the default
        Returns:
        the builder
      • streaming

        public ServiceEndpointsBuilder streaming​(java.lang.String streamingBaseUri)
        Equivalent to streaming(URI), specifying the URI as a string.
        Parameters:
        streamingBaseUri - the base URI of the events service; null to use the default
        Returns:
        the builder
      • createServiceEndpoints

        public abstract ServiceEndpoints createServiceEndpoints()
        Called internally by the SDK to create a configuration instance. Applications do not need to call this method.
        Returns:
        the configuration object