github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/server/context.go (about) 1 package server 2 3 import "context" 4 5 type maxNodesKeyType int 6 7 const currentMaxNodes maxNodesKeyType = iota 8 9 func ContextWithMaxNodes(parent context.Context, val int) context.Context { 10 return context.WithValue(parent, currentMaxNodes, val) 11 } 12 13 func MaxNodesFromContext(ctx context.Context) (int, bool) { 14 v, ok := ctx.Value(currentMaxNodes).(int) 15 return v, ok 16 }