Skip to content

Commit

Permalink
doc(gmm): add some comments for get free port
Browse files Browse the repository at this point in the history
  • Loading branch information
hedon954 committed Aug 22, 2024
1 parent a004a9b commit 572fb4c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gmm/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ func (b *GMMBuilder) Build() (sDB *sql.DB, gDB *gorm.DB, shutdown func(), err er
return nil, nil, nil, b.err
}

// Get port
// If not specify port, get an unused one form local machine.
//
// NOTE: The `getFreePort` method indeed has the limitation
// that it cannot guarantee the port will remain available.
// While it can find a currently unused port,
// there is a possibility that the port might be occupied
// by another process between the time the port number is
// retrieved and the moment it is actually used.
if b.port == 0 {
var listener net.Listener
listener, b.port, b.err = getFreePort()
Expand Down

0 comments on commit 572fb4c

Please sign in to comment.