-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* splits out websocket provider configuration into its own file * expose the retry and delay settings for `find` in the repo initializers
- Loading branch information
Showing
3 changed files
with
90 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Sources/AutomergeRepo/Networking/Providers/WebSocketProviderConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Automerge | ||
|
||
/// The configuration options for a WebSocket network provider. | ||
public struct WebSocketProviderConfiguration: Sendable { | ||
/// A Boolean value that indicates if the provider should attempt to reconnect when it fails with an error. | ||
public let reconnectOnError: Bool | ||
/// The maximum number of reconnections allowed before the WebSocket provider disconnects. | ||
/// | ||
/// If ``reconnectOnError`` is `false`, this value is ignored. | ||
/// If `nil`, the default, the WebSocketProvider does not enforce a maximum number of retries. | ||
public let maxNumberOfConnectRetries: Int? | ||
/// The verbosity of the logs sent to the unified logging system. | ||
public let logLevel: LogVerbosity | ||
|
||
/// The default configuration for the WebSocket network provider. | ||
/// | ||
/// In the default configuration: | ||
/// | ||
/// - `reconnectOnError` is `true` | ||
public static let `default` = WebSocketProviderConfiguration(reconnectOnError: true) | ||
|
||
/// Creates a new WebSocket network provider configuration instance. | ||
/// - Parameter reconnectOnError: A Boolean value that indicates if the provider should attempt to reconnect | ||
/// when it fails with an error. | ||
/// - Parameter loggingAt: The verbosity of the logs sent to the unified logging system. | ||
public init(reconnectOnError: Bool, loggingAt: LogVerbosity = .errorOnly, maxNumberOfConnectRetries: Int? = nil) { | ||
self.reconnectOnError = reconnectOnError | ||
self.maxNumberOfConnectRetries = maxNumberOfConnectRetries | ||
self.logLevel = loggingAt | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters