Show / Hide Table of Contents

Class ServiceEndpointsBuilder

Contains methods for configuring the SDK's service URIs.

Inheritance
System.Object
ServiceEndpointsBuilder
Namespace: LaunchDarkly.Sdk.Client.Integrations
Assembly: LaunchDarkly.ClientSdk.dll
Syntax
public class ServiceEndpointsBuilder : Object
Remarks

If you want to set non-default values for any of these properties, create a builder with ServiceEndpoints(), change its properties with the methods of this class, and pass it to 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) to the base URI of the Relay Proxy instance. Note that this is not the same as a regular HTTP proxy, which would be set with Proxy(IWebProxy).
  • 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 System.Uri or an equivalent string. Passing a string that is not a valid URI will cause an immediate System.UriFormatException

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 NoEvents, you do not have to set Events(Uri).

Examples
    // Example of specifying a Relay Proxy instance
    var config = Configuration.Builder(mobileKey)
        .ServiceEndpoints(Components.ServiceEndpoints()
            .RelayProxy("http://my-relay-hostname:8080"))
        .Build();

    // Example of specifying a private LaunchDarkly instance
    var config = Configuration.Builder(mobileKey)
        .ServiceEndpoints(Components.ServiceEndpoints()
            .Streaming("https://stream.mycompany.launchdarkly.com")
            .Polling("https://app.mycompany.launchdarkly.com")
            .Events("https://events.mycompany.launchdarkly.com"))
        .Build();

Methods

Build()

Called internally by the SDK to create a configuration instance. Applications do not need to call this method.

Declaration
public ServiceEndpoints Build()
Returns
Type Description
ServiceEndpoints

the configuration object

Events(String)

Equivalent to Events(Uri), specifying the URI as a string.

Declaration
public ServiceEndpointsBuilder Events(string eventsBaseUri)
Parameters
Type Name Description
System.String eventsBaseUri

the base URI of the events service, or null to reset to the default

Returns
Type Description
ServiceEndpointsBuilder

the same builder

Exceptions
Type Condition
System.UriFormatException

if the string is not null and is not a valid URI

See Also
Events(Uri)

Events(Uri)

Sets a custom base URI for the events service.

Declaration
public ServiceEndpointsBuilder Events(Uri eventsBaseUri)
Parameters
Type Name Description
System.Uri eventsBaseUri

the base URI of the events service; null to use the default

Returns
Type Description
ServiceEndpointsBuilder

the builder

Remarks

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

Examples

var config = Configuration.Builder(mobileKey) .ServiceEndpoints(Components.ServiceEndpoints() .Streaming("https://stream.mycompany.launchdarkly.com") .Polling("https://app.mycompany.launchdarkly.com") .Events("https://events.mycompany.launchdarkly.com")) .Build();

See Also
Events(String)

Polling(String)

Equivalent to Polling(Uri), specifying the URI as a string.

Declaration
public ServiceEndpointsBuilder Polling(string pollingBaseUri)
Parameters
Type Name Description
System.String pollingBaseUri

the base URI of the polling service, or null to reset to the default

Returns
Type Description
ServiceEndpointsBuilder

the same builder

Exceptions
Type Condition
System.UriFormatException

if the string is not null and is not a valid URI

See Also
Polling(Uri)

Polling(Uri)

Sets a custom base URI for the polling service.

Declaration
public ServiceEndpointsBuilder Polling(Uri pollingBaseUri)
Parameters
Type Name Description
System.Uri pollingBaseUri

the base URI of the polling service; null to use the default

Returns
Type Description
ServiceEndpointsBuilder

the builder

Remarks

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

Examples

var config = Configuration.Builder(mobileKey) .ServiceEndpoints(Components.ServiceEndpoints() .Streaming("https://stream.mycompany.launchdarkly.com") .Polling("https://app.mycompany.launchdarkly.com") .Events("https://events.mycompany.launchdarkly.com")) .Build();

See Also
Polling(String)

RelayProxy(String)

Equivalent to RelayProxy(Uri), specifying the URI as a string.

Declaration
public ServiceEndpointsBuilder RelayProxy(string relayProxyBaseUri)
Parameters
Type Name Description
System.String relayProxyBaseUri

the Relay Proxy base URI, or null to reset to default endpoints

Returns
Type Description
ServiceEndpointsBuilder

the same builder

Exceptions
Type Condition
System.UriFormatException

if the string is not null and is not a valid URI

See Also
RelayProxy(Uri)

RelayProxy(Uri)

Specifies a single base URI for a Relay Proxy instance.

Declaration
public ServiceEndpointsBuilder RelayProxy(Uri relayProxyBaseUri)
Parameters
Type Name Description
System.Uri relayProxyBaseUri

the Relay Proxy base URI, or null to reset to default endpoints

Returns
Type Description
ServiceEndpointsBuilder

the builder

Remarks

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

Note that this is not the same as a regular HTTP proxy, which would be set with Proxy(IWebProxy).

Examples
    var relayUri = new Uri("http://my-relay-hostname:8080");
    var config = Configuration.Builder(mobileKey)
        .ServiceEndpoints(Components.ServiceEndpoints().RelayProxy(relayUri))
        .Build();
See Also
RelayProxy(String)

Streaming(String)

Equivalent to Streaming(Uri), specifying the URI as a string.

Declaration
public ServiceEndpointsBuilder Streaming(string streamingBaseUri)
Parameters
Type Name Description
System.String streamingBaseUri

the base URI of the streaming service, or null to reset to the default

Returns
Type Description
ServiceEndpointsBuilder

the same builder

Exceptions
Type Condition
System.UriFormatException

if the string is not null and is not a valid URI

See Also
Streaming(Uri)

Streaming(Uri)

Sets a custom base URI for the streaming service.

Declaration
public ServiceEndpointsBuilder Streaming(Uri streamingBaseUri)
Parameters
Type Name Description
System.Uri streamingBaseUri

the base URI of the streaming service; null to use the default

Returns
Type Description
ServiceEndpointsBuilder

the builder

Remarks

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

If you set a custom Streaming URI, you must also set a custom Polling URI. Even when in streaming mode, the SDK may sometimes need to make a request to the polling service.

Examples

var config = Configuration.Builder(mobileKey) .ServiceEndpoints(Components.ServiceEndpoints() .Streaming("https://stream.mycompany.launchdarkly.com") .Polling("https://app.mycompany.launchdarkly.com") .Events("https://events.mycompany.launchdarkly.com")) .Build();

See Also
Streaming(String)
In This Article
Back to top Generated by DocFX