-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,34 @@ | |
|
||
namespace Realms.Sync.Native | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct ReconnectBackoffOptions | ||
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (ubuntu-latest, linux-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (ubuntu-latest, linux-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (ubuntu-latest, linux-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (ubuntu-latest, linux-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (macos-14, osx-arm64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (macos-14, osx-arm64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (macos-14, osx-arm64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (macos-14, osx-arm64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Source Generation
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (windows-latest, win-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (windows-latest, win-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (windows-latest, win-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Test Weaver (windows-latest, win-x64)
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Analyze C#
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Analyze C#
Check warning on line 25 in Realm/Realm/Native/AppConfiguration.cs GitHub Actions / Analyze C#
|
||
{ | ||
internal UInt64 max_resumption_delay_interval_ms; | ||
|
||
internal UInt64 resumption_delay_interval_ms; | ||
|
||
internal int resumption_delay_backoff_multiplier; | ||
|
||
internal int delay_jitter_divisor; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct SyncTimeoutOptions | ||
{ | ||
internal UInt64 sync_connect_timeout_ms; | ||
|
||
internal UInt64 sync_connection_linger_time_ms; | ||
|
||
internal UInt64 sync_ping_keep_alive_period_ms; | ||
|
||
internal UInt64 sync_pong_keep_alive_timeout_ms; | ||
|
||
internal UInt64 sync_fast_reconnect_limit; | ||
|
||
internal ReconnectBackoffOptions reconnect_backoff_options; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct AppConfiguration | ||
{ | ||
|
@@ -83,15 +111,7 @@ internal MetadataPersistenceMode? MetadataPersistence | |
|
||
internal IntPtr managed_websocket_provider; | ||
|
||
internal UInt64 sync_connect_timeout_ms; | ||
|
||
internal UInt64 sync_connection_linger_time_ms; | ||
|
||
internal UInt64 sync_ping_keep_alive_period_ms; | ||
|
||
internal UInt64 sync_pong_keep_alive_timeout_ms; | ||
|
||
internal UInt64 sync_fast_reconnect_limit; | ||
internal SyncTimeoutOptions sync_timeout_options; | ||
|
||
[MarshalAs(UnmanagedType.U1)] | ||
internal bool use_cache; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2024 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
using System; | ||
|
||
namespace Realms.Sync | ||
{ | ||
/// <summary> | ||
/// Options for configuring the reconnection delay used by the sync client. | ||
/// </summary> | ||
/// <remarks> | ||
/// The sync client employs an exponential backoff delay strategy when reconnecting to the server. | ||
/// In order to not spam the network interface the sync client performs an increasing wait before reconnecting. | ||
/// The wait starts from <see cref="ReconnectDelayInterval"/> and multiplies by <see cref="ReconnectDelayBackoffMultiplier"/> | ||
/// until it reaches <see cref="MaxReconnectDelayInterval"/>. | ||
/// </remarks> | ||
public class ReconnectBackoffOptions | ||
{ | ||
/// <summary> | ||
/// Gets or sets the maximum amount of time to wait before a reconnection attempt. | ||
/// </summary> | ||
/// <remarks> | ||
/// Defaults to 5 minutes. | ||
/// </remarks> | ||
/// <value> | ||
/// The maximum amount of time to wait before a reconnection attempt. | ||
/// </value> | ||
public TimeSpan MaxReconnectDelayInterval { get; set; } = TimeSpan.FromMinutes(5); | ||
|
||
/// <summary> | ||
/// Gets or sets the initial amount of time to wait before a reconnection attempt. | ||
/// </summary> | ||
/// <remarks> | ||
/// Defaults to 1 second. | ||
/// </remarks> | ||
/// <value> | ||
/// The initial amount of time to wait before a reconnection attempt. | ||
/// </value> | ||
public TimeSpan ReconnectDelayInterval { get; set; } = TimeSpan.FromSeconds(1); | ||
|
||
/// <summary> | ||
/// Gets or sets the multiplier to apply to the accumulated reconnection delay before a new reconection attempt. | ||
/// </summary> | ||
/// <remarks> | ||
/// Defaults to 2. | ||
/// </remarks> | ||
/// <value> | ||
/// The delay multiplier. | ||
/// </value> | ||
public int ReconnectDelayBackoffMultiplier { get; set; } = 2; | ||
|
||
/// <summary> | ||
/// Gets or sets the jitter randomization factor to apply to the delay. | ||
/// </summary> | ||
/// <remarks> | ||
/// The reconnection delay is subtracted by a value derived from this divisor so that if a lot of clients lose connection and reconnect at the same time the server won't be overwhelmed. | ||
/// <br /> | ||
/// Defaults to 4. | ||
/// </remarks> | ||
/// <value> | ||
/// The jitter randomization factor to apply to the delay. | ||
/// </value> | ||
public int DelayJitterDivisor { get; set; } = 4; | ||
} | ||
} |