Skip to content

Commit

Permalink
Comment exported functions from allocation package
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean-Der committed May 16, 2018
1 parent 66d5427 commit 80cf10d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/allocation/reservation_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type reservation struct {
var reservationsLock sync.RWMutex
var reservations []*reservation

// CreateReservation stores the reservation for the token+port
func CreateReservation(reservationToken string, port int) {
time.AfterFunc(30*time.Second, func() {
reservationsLock.Lock()
Expand All @@ -36,6 +37,7 @@ func CreateReservation(reservationToken string, port int) {
reservationsLock.Unlock()
}

// GetReservation returns the port for a given reservation if it exists
func GetReservation(reservationToken string) (int, bool) {
reservationsLock.RLock()
defer reservationsLock.RUnlock()
Expand All @@ -48,6 +50,7 @@ func GetReservation(reservationToken string) (int, bool) {
return 0, false
}

// GetRandomEvenPort returns a random unallocated udp4 port
func GetRandomEvenPort() (int, error) {
listener, err := net.ListenPacket("udp4", "0.0.0.0:0")
if err != nil {
Expand Down

0 comments on commit 80cf10d

Please sign in to comment.