Skip to content

Commit

Permalink
fix: try fix check connection
Browse files Browse the repository at this point in the history
  • Loading branch information
gulivero1773 committed Jun 6, 2024
1 parent 070d032 commit 6e46054
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Sources/HealthChecks/MongoHealthChecks/MongoRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,12 @@ public final class MongoRequest: MongoRequestSendable {

// WARNING: - This method create new connection every time, when you use it
/// Get mongo connection
/// - Parameter url: `String`
/// - Parameter host: `String`
/// - Parameter port: `String`
/// - Returns: `String`
public func getConnection(by host: String, and port: String) async throws -> String {

let connect = try await app.client.get(URI(string: "http://\(host):\(port)" + "?compressors=disabled&gssapiServiceName=mongodb"))
// await app.mongoCluster?.disconnect()
// app.mongoCluster = nil
// app.mongoCluster = try? MongoCluster(lazyConnectingTo: ConnectionSettings(url))
// let connection = "\(app.mongoCluster?.connectionState ?? .disconnected)"
// await app.mongoCluster?.disconnect()
// app.mongoCluster = nil

let uri = URI(string: "http://\(host):\(port)" + "?compressors=disabled&gssapiServiceName=mongodb")
let connect = try await app.client.get(uri)
return "\(connect.status)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import Vapor
/// Groups func for get mongo request
public protocol MongoRequestSendable {
/// Get connection description
/// - Parameter host: `String`
/// - Parameter port: `String`
/// - Returns: `String`
func getConnection(by host: String, and port: String) async throws -> String
}

0 comments on commit 6e46054

Please sign in to comment.