1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-23 20:32:32 +02:00

27 lines
430 B
Go
Raw Normal View History

2020-12-26 15:32:45 +00:00
package label
import (
"context"
2021-10-12 12:55:53 +01:00
"go-micro.dev/v4/selector"
2020-12-26 15:32:45 +00:00
)
type labelKey struct{}
type label struct {
key string
val string
}
// Label used in the priority label list
func Label(k, v string) selector.Option {
return func(o *selector.Options) {
l, ok := o.Context.Value(labelKey{}).([]label)
if !ok {
l = []label{}
}
l = append(l, label{k, v})
o.Context = context.WithValue(o.Context, labelKey{}, l)
}
}