Skip to content

Commit

Permalink
cleaning up documentation - resolving warnings, tweaking a few abstra…
Browse files Browse the repository at this point in the history
…cts, matching code updates (#123)
  • Loading branch information
heckj authored Nov 1, 2024
1 parent b9f167d commit cdeb805
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/automerge/automerge-swift",
"state" : {
"revision" : "410b1d1b8bec078227dbb4fe8c16e1a4541d01cb",
"version" : "0.5.18"
"revision" : "c8daf47b5cb77ae5eec451a4e4b77ad6f6db8f5e",
"version" : "0.5.19"
}
},
{
Expand Down Expand Up @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-distributed-tracing",
"state" : {
"revision" : "11c756c5c4d7de0eeed8595695cadd7fa107aa19",
"version" : "1.1.1"
"revision" : "6483d340853a944c96dbcc28b27dd10b6c581703",
"version" : "1.1.2"
}
},
{
Expand Down
14 changes: 8 additions & 6 deletions Sources/AutomergeRepo/Documentation.docc/Curation/Repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ When network providers are active, the repository attempts to sync documents wit

### Creating a repository

- ``init(sharePolicy:saveDebounce:)-9tksd``
- ``init(sharePolicy:saveDebounce:)-8umfb``
- ``init(sharePolicy:storage:saveDebounce:)``
- ``init(sharePolicy:storage:networks:saveDebounce:)``
- ``init(sharePolicy:saveDebounce:maxResolveFetchIterations:resolveFetchIterationDelay:)-3j0z7``
- ``init(sharePolicy:saveDebounce:maxResolveFetchIterations:resolveFetchIterationDelay:)-18my9``
- ``init(sharePolicy:storage:saveDebounce:maxResolveFetchIterations:resolveFetchIterationDelay:)``
- ``init(sharePolicy:storage:networks:saveDebounce:maxResolveFetchIterations:resolveFetchIterationDelay:)``

### Configuring a repository

Expand All @@ -29,8 +29,10 @@ When network providers are active, the repository attempts to sync documents wit

- ``create()``
- ``create(id:)``
- ``create(data:id:)``
- ``create(doc:id:)``

### Importing a document

- ``import(handle:)``

### Cloning a document

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct MeetingNotesApp: App {
}
```

To connect the repository to a remote endpoint, make an async call to ``connect(to:)``, passing the WebSocket URL:
To connect the repository to a remote endpoint, make an async call to ``connect(to:)-32her``, passing the WebSocket URL:

```swift
Button {
Expand All @@ -44,14 +44,16 @@ Button {
- ``init(_:)``
- ``WebSocketProviderConfiguration``
- ``ProviderConfiguration``
- ``NetworkConnectionEndpoint``

### Configuring the provider

- ``setDelegate(_:as:with:)``

### Establishing Connections

- ``connect(to:)``
- ``connect(to:)-32her``
- ``connect(to:)-5y82b``
- ``disconnect()``

### Sending messages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ``AutomergeRepo/WebSocketProvider/WebSocketProviderConfiguration``
# ``AutomergeRepo/WebSocketProviderConfiguration``

## Topics

Expand All @@ -8,9 +8,10 @@

### Creating a configuration

- ``init(_:)``
- ``init(reconnectOnError:loggingAt:)``
- ``init(reconnectOnError:loggingAt:maxNumberOfConnectRetries:)``

### Inspecting a configuration

- ``reconnectOnError``
- ``maxNumberOfConnectRetries``
- ``logLevel``
2 changes: 1 addition & 1 deletion Sources/AutomergeRepo/Networking/NetworkProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public protocol NetworkProvider: Sendable {
/// Set the delegate for the peer to peer provider.
/// - Parameters:
/// - delegate: The delegate instance.
/// - peerId: The peer ID to use for the peer to peer provider.
/// - peer: The peer ID to use for the peer to peer provider.
/// - metadata: The peer metadata, if any, to use for the peer to peer provider.
///
/// This is typically called when the delegate adds the provider, and provides this network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public final class PeerToPeerProvider: NetworkProvider {

/// Requests the network transport to send a message.
/// - Parameter message: The message to send.
/// - Parameter to: An option peerId to identify the recipient for the message. If nil, the message is sent to all
/// - Parameter peer: An option peerId to identify the recipient for the message. If nil, the message is sent to all
/// connected peers.
public func send(message: SyncV1Msg, to peer: PEER_ID?) async {
if let peerId = peer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal import OSLog
/// An Automerge-repo network provider that connects to other repositories using WebSocket.
@AutomergeRepo
public final class WebSocketProvider: NetworkProvider {
/// The type that represents the endpoint that this provider connects with.
public typealias NetworkConnectionEndpoint = URL

/// The name of this provider.
Expand Down Expand Up @@ -50,16 +51,16 @@ public final class WebSocketProvider: NetworkProvider {
peered = false
}

/// Initiate an outgoing connection.
/// Initiate an outgoing connection to a URL.
///
/// Create a default `URLRequest` and create a WebSocket connection with it.
/// Creates a default `URLRequest` from the `URL` you provide and creates a WebSocket connection with it.
public func connect(to url: URL) async throws {
try await connect(to: URLRequest(url: url))
}

/// Initiate an outgoing connection.
/// Initiate an outgoing connection to a URL Request.
///
/// Create a WebSocket connection with the provided `URLRequest`.
/// Create a WebSocket connection with the `URLRequest` you provide.
public func connect(to request: URLRequest) async throws {
if peered {
Logger.websocket.error("Attempting to connect while already peered")
Expand Down Expand Up @@ -150,7 +151,7 @@ public final class WebSocketProvider: NetworkProvider {
/// Set the delegate for the peer to peer provider.
/// - Parameters:
/// - delegate: The delegate instance.
/// - peerId: The peer ID to use for the peer to peer provider.
/// - peer: The peer ID to use for the peer to peer provider.
/// - metadata: The peer metadata, if any, to use for the peer to peer provider.
///
/// This is typically called when the delegate adds the provider, and provides this network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public struct WebSocketProviderConfiguration: Sendable {
/// - 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.
/// - Parameter maxNumberOfConnectRetries: The maximum number of reconnections allowed before the WebSocket provider disconnects. If `nil`, the default, retries continue forever.
public init(reconnectOnError: Bool, loggingAt: LogVerbosity = .errorOnly, maxNumberOfConnectRetries: Int? = nil) {
self.reconnectOnError = reconnectOnError
self.maxNumberOfConnectRetries = maxNumberOfConnectRetries
Expand Down
2 changes: 1 addition & 1 deletion Sources/AutomergeRepo/ShareAuthorizing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol ShareAuthorizing: Sendable {
///
/// If you need a type that supports more state and logic to determine authorization to share,
/// initialize a ``Repo`` with your own type that conforms to ``ShareAuthorizing`` with
/// ``Repo/init(sharePolicy:saveDebounce:)-8umfb``.
/// ``Repo/init(sharePolicy:saveDebounce:maxResolveFetchIterations:resolveFetchIterationDelay:)-3j0z7``.
public struct SharePolicy: ShareAuthorizing, Sendable {
/// Returns a Boolean value that indicates whether a document may be shared.
/// - Parameters:
Expand Down
5 changes: 0 additions & 5 deletions Sources/AutomergeRepo/Sync/SyncV1Msg+encode+decode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ public extension SyncV1Msg {
///
/// - Parameters:
/// - data: The data to decode.
/// - withGossip: A Boolean value that indicates whether to include decoding of handshake messages.
/// - withHandshake: A Boolean value that indicates whether to include decoding of gossip messages.
/// - Returns: The decoded message, or ``SyncV1Msg/unknown(_:)`` if the previous decoding attempts failed.
///
/// The decoding is ordered from the perspective of an initiating client expecting a response to minimize attempts.
/// Enable `withGossip` to attempt to decode head gossip messages, and `withHandshake` to include handshake phase
/// messages.
/// With both `withGossip` and `withHandshake` set to `true`, the decoding is exhaustive over all V1 messages.
static func decode(_ data: Data) -> SyncV1Msg {
var cborMsg: CBOR? = nil

Expand Down

0 comments on commit cdeb805

Please sign in to comment.