ConnectionMigrationOptions.Builder

class ConnectionMigrationOptions.Builder


Builder for ConnectionMigrationOptions.

Summary

Public functions

ConnectionMigrationOptions.Builder!

Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use.

ConnectionMigrationOptions.Builder!

Enables the possibility of migrating connections to an alternate server address at the server's request.

ConnectionMigrationOptions!

Creates and returns the final ConnectionMigrationOptions instance, based on the values in this builder.

ConnectionMigrationOptions.Builder!
enableDefaultNetworkMigration(
    enableDefaultNetworkConnectionMigration: Boolean
)

Enables the possibility of migrating connections on default network change.

ConnectionMigrationOptions.Builder!

Enables the possibility of migrating connections if the current path is performing poorly.

ConnectionMigrationOptions.Builder!

Configures whether migration of idle connections should be enabled or not.

ConnectionMigrationOptions.Builder!

Sets whether connections with pre-handshake errors should be retried on an alternative network.

ConnectionMigrationOptions.Builder!

Sets the maximum idle period for which connections will still be migrated, in seconds.

ConnectionMigrationOptions.Builder!

Sets the maximum number of migrations to the non-default network upon encountering path degradation for the existing connection.

ConnectionMigrationOptions.Builder!

Sets the maximum period for which eagerly migrated connections should remain on the non-default network before they're migrated back.

ConnectionMigrationOptions.Builder!

Sets the maximum number of migrations to the non-default network upon encountering write errors.

Public functions

allowNonDefaultNetworkUsage

@ConnectionMigrationOptions.Experimental
fun allowNonDefaultNetworkUsage(enable: Boolean): ConnectionMigrationOptions.Builder!

Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use.

Note: This setting can result in requests being sent on non-default metered networks. Make sure you're using metered networks sparingly, and fine tune parameters like setMaxPathDegradingNonDefaultNetworkMigrationsCount and setMaxTimeOnNonDefaultNetworkSeconds to limit the time on non-default networks.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

allowServerMigration

@ConnectionMigrationOptions.Experimental
fun allowServerMigration(allowServerMigration: Boolean): ConnectionMigrationOptions.Builder!

Enables the possibility of migrating connections to an alternate server address at the server's request.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

build

fun build(): ConnectionMigrationOptions!

Creates and returns the final ConnectionMigrationOptions instance, based on the values in this builder.

enableDefaultNetworkMigration

fun enableDefaultNetworkMigration(
    enableDefaultNetworkConnectionMigration: Boolean
): ConnectionMigrationOptions.Builder!

Enables the possibility of migrating connections on default network change. If enabled, active QUIC connections will be migrated onto the new network when the platform indicates that the default network is changing.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

enablePathDegradationMigration

fun enablePathDegradationMigration(enable: Boolean): ConnectionMigrationOptions.Builder!

Enables the possibility of migrating connections if the current path is performing poorly.

Depending on other configuration, this can result to migrating the connections within the same default network, or to a non-default network.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

migrateIdleConnections

@ConnectionMigrationOptions.Experimental
fun migrateIdleConnections(migrateIdleConnections: Boolean): ConnectionMigrationOptions.Builder!

Configures whether migration of idle connections should be enabled or not.

If set to true, idle connections will be migrated too, as long as they haven't been idle for too long. The setting is shared for all connection migration types. The maximum idle period for which connections will still be migrated can be customized using setIdleConnectionMigrationPeriodSeconds.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

retryPreHandshakeErrorsOnNonDefaultNetwork

@ConnectionMigrationOptions.Experimental
fun retryPreHandshakeErrorsOnNonDefaultNetwork(
    retryPreHandshakeErrorsOnAlternateNetwork: Boolean
): ConnectionMigrationOptions.Builder!

Sets whether connections with pre-handshake errors should be retried on an alternative network.

If true, a new connection may be established an alternate network if it fails on the default network before handshake is confirmed.

Note: similarly to allowNonDefaultNetworkUsage this setting can result in requests being sent on non-default metered networks. Use with caution!

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

setIdleConnectionMigrationPeriodSeconds

@ConnectionMigrationOptions.Experimental
fun setIdleConnectionMigrationPeriodSeconds(
    idleConnectionMigrationPeriodSeconds: Long
): ConnectionMigrationOptions.Builder!

Sets the maximum idle period for which connections will still be migrated, in seconds. The setting is shared for all connection migration types.

Only relevant if migrateIdleConnections is enabled.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

setMaxPathDegradingNonDefaultNetworkMigrationsCount

@ConnectionMigrationOptions.Experimental
fun setMaxPathDegradingNonDefaultNetworkMigrationsCount(
    maxPathDegradingEagerMigrationsCount: Int
): ConnectionMigrationOptions.Builder!

Sets the maximum number of migrations to the non-default network upon encountering path degradation for the existing connection. Counted cumulatively per network per connection.

Only relevant if allowNonDefaultNetworkUsage is enabled.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

setMaxTimeOnNonDefaultNetworkSeconds

@ConnectionMigrationOptions.Experimental
fun setMaxTimeOnNonDefaultNetworkSeconds(
    maxTimeOnNonDefaultNetworkSeconds: Long
): ConnectionMigrationOptions.Builder!

Sets the maximum period for which eagerly migrated connections should remain on the non-default network before they're migrated back. This time is not cumulative - each migration off the default network for each connection measures and compares to this value separately.

Only relevant if allowNonDefaultNetworkUsage is enabled.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining

setMaxWriteErrorNonDefaultNetworkMigrationsCount

@ConnectionMigrationOptions.Experimental
fun setMaxWriteErrorNonDefaultNetworkMigrationsCount(
    maxWriteErrorEagerMigrationsCount: Int
): ConnectionMigrationOptions.Builder!

Sets the maximum number of migrations to the non-default network upon encountering write errors. Counted cumulatively per network per connection.

Only relevant if allowNonDefaultNetworkUsage is enabled.

Returns
ConnectionMigrationOptions.Builder!

this builder for chaining