1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-26 03:52:12 +02:00
kratos/selector/global.go
Cluas 383f28faeb
fix(selector): set global do not work (#2489)
* fix(selector): set global do not work

* fix(selector): test

* fix(selector): return early

* fix(selector): use struct

* fix(selector): use struct
2022-11-09 17:36:36 +08:00

22 lines
500 B
Go

package selector
var globalSelector = &wrapSelector{}
var _ Builder = (*wrapSelector)(nil)
// wrapSelector wrapped Selector, help override global Selector implementation.
type wrapSelector struct{ Builder }
// GlobalSelector returns global selector builder.
func GlobalSelector() Builder {
if globalSelector.Builder != nil {
return globalSelector
}
return nil
}
// SetGlobalSelector set global selector builder.
func SetGlobalSelector(builder Builder) {
globalSelector.Builder = builder
}