forked from TrueCloudLab/frostfs-qos
21 lines
458 B
Go
21 lines
458 B
Go
package tagging
|
|
|
|
import "context"
|
|
|
|
type tagContextKeyType struct{}
|
|
|
|
var currentTagKey = tagContextKeyType{}
|
|
|
|
func ContextWithIOTag(parent context.Context, ioTag string) context.Context {
|
|
return context.WithValue(parent, currentTagKey, ioTag)
|
|
}
|
|
|
|
func IOTagFromContext(ctx context.Context) (string, bool) {
|
|
if ctx == nil {
|
|
panic("context must be non nil")
|
|
}
|
|
if tag, ok := ctx.Value(currentTagKey).(string); ok {
|
|
return tag, true
|
|
}
|
|
return "", false
|
|
}
|