mirror of
https://github.com/fluxcd/flagger.git
synced 2026-02-27 16:23:53 +00:00
32 lines
512 B
Go
32 lines
512 B
Go
package loadtester
|
|
|
|
import "sync"
|
|
|
|
type GateStorage struct {
|
|
backend string
|
|
data *sync.Map
|
|
}
|
|
|
|
func NewGateStorage(backend string) *GateStorage {
|
|
return &GateStorage{
|
|
backend: backend,
|
|
data: new(sync.Map),
|
|
}
|
|
}
|
|
|
|
func (gs *GateStorage) open(key string) {
|
|
gs.data.Store(key, true)
|
|
}
|
|
|
|
func (gs *GateStorage) close(key string) {
|
|
gs.data.Store(key, false)
|
|
}
|
|
|
|
func (gs *GateStorage) isOpen(key string) (locked bool) {
|
|
val, ok := gs.data.LoadOrStore(key, false)
|
|
if ok {
|
|
return val.(bool)
|
|
}
|
|
return
|
|
}
|