chore: apply lint recommendations

This commit is contained in:
Adrien Raffin-Caboisse
2022-05-16 14:59:46 +02:00
parent 02ae7a0563
commit 4435a4f19d
6 changed files with 26 additions and 17 deletions

10
poll.go
View File

@@ -20,6 +20,10 @@ const (
updateCheckInterval = 10 * time.Second
)
type contextKey string
const machineNameContextKey = contextKey("machineName")
// PollNetMapHandler takes care of /machine/:id/map
//
// This is the busiest endpoint, as it keeps the HTTP long poll that updates
@@ -272,7 +276,7 @@ func (h *Headscale) PollNetMapStream(
return
}
ctx := context.WithValue(ctx.Request.Context(), "machineName", machine.Name)
ctx := context.WithValue(ctx.Request.Context(), machineNameContextKey, machine.Name)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -576,12 +580,12 @@ func (h *Headscale) scheduledPollWorker(
defer closeChanWithLog(
updateChan,
fmt.Sprint(ctx.Value("machineName")),
fmt.Sprint(ctx.Value(machineNameContextKey)),
"updateChan",
)
defer closeChanWithLog(
keepAliveChan,
fmt.Sprint(ctx.Value("machineName")),
fmt.Sprint(ctx.Value(machineNameContextKey)),
"updateChan",
)