Skip to content

Commit

Permalink
Refactor connect (#37)
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
  • Loading branch information
piotrpio authored Feb 21, 2024
1 parent c6f6cef commit 9aa1350
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 275 deletions.
8 changes: 5 additions & 3 deletions Sources/NatsSwift/NatsClient/NatsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ public class Client {

extension Client {
public func connect() async throws {
//TODO(jrm): reafactor for reconnection and review error handling.
//TODO(jrm): handle response
logger.debug("connect")
guard let connectionHandler = self.connectionHandler else {
throw NatsClientError("internal error: empty connection handler")
}
try await connectionHandler.connect()
if !connectionHandler.retryOnFailedConnect {
try await connectionHandler.connect()
} else {
connectionHandler.handleReconnect()
}
}

public func close() async throws {
Expand Down
Loading

0 comments on commit 9aa1350

Please sign in to comment.