Class ServiceEndpointsBuilder
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)
, andevents(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, 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:
- 4.0.0
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract ServiceEndpoints
Called internally by the SDK to create a configuration instance.Equivalent toevents(URI)
, specifying the URI as a string.Sets a custom base URI for the events service.Equivalent topolling(URI)
, specifying the URI as a string.Sets a custom base URI for the polling service.relayProxy
(String relayProxyBaseUri) Equivalent torelayProxy(URI)
, specifying the URI as a string.relayProxy
(URI relayProxyBaseUri) Specifies a single base URI for a Relay Proxy instance.Equivalent tostreaming(URI)
, specifying the URI as a string.Sets a custom base URI for the streaming service.
-
Field Details
-
streamingBaseUri
Base URI for streaming requests -
pollingBaseUri
Base URI for polling requests -
eventsBaseUri
Base URI for events
-
-
Constructor Details
-
ServiceEndpointsBuilder
public ServiceEndpointsBuilder()
-
-
Method Details
-
events
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, callrelayProxy(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
Equivalent toevents(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
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, callrelayProxy(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
Equivalent topolling(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
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
Equivalent torelayProxy(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
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, callrelayProxy(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
Equivalent tostreaming(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
Called internally by the SDK to create a configuration instance. Applications do not need to call this method.- Returns:
- the configuration object
-