Skip to content

Commit 770179d

Browse files
hasaketaCopilot
andauthored
Update main.go
Co-authored-by: Copilot <[email protected]>
1 parent 96d00c1 commit 770179d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ func isDirectoryExist(OutputPrefix string) bool {
5252
return !os.IsNotExist(err)
5353
}
5454

55+
// isMongoNodeAlive checks if a MongoDB node is reachable at the specified hostname and port.
56+
// It attempts to establish a TCP connection to the given address within a 5-second timeout.
57+
// Parameters:
58+
// - hostname: The hostname or IP address of the MongoDB node.
59+
// - port: The port number on which the MongoDB node is listening.
60+
// Returns:
61+
// - bool: True if the node is reachable, false otherwise.
62+
// - error: An error object if the connection attempt fails.
5563
func isMongoNodeAlive(hostname string, port int) (bool, error) {
5664
// Attempt to connect to the MongoDB host on the specified port
5765
conn, err := net.DialTimeout("tcp", net.JoinHostPort(hostname, strconv.Itoa(port)), 5*time.Second)

0 commit comments

Comments
 (0)