github.com/iaas-resource-provision/iaas-rpc@v1.0.7-0.20211021023331-ed21f798c408/internal/states/statemgr/lock.go (about) 1 package statemgr 2 3 import "github.com/iaas-resource-provision/iaas-rpc/internal/states" 4 5 // LockDisabled implements State and Locker but disables state locking. 6 // If State doesn't support locking, this is a no-op. This is useful for 7 // easily disabling locking of an existing state or for tests. 8 type LockDisabled struct { 9 // We can't embed State directly since Go dislikes that a field is 10 // State and State interface has a method State 11 Inner Full 12 } 13 14 func (s *LockDisabled) State() *states.State { 15 return s.Inner.State() 16 } 17 18 func (s *LockDisabled) WriteState(v *states.State) error { 19 return s.Inner.WriteState(v) 20 } 21 22 func (s *LockDisabled) RefreshState() error { 23 return s.Inner.RefreshState() 24 } 25 26 func (s *LockDisabled) PersistState() error { 27 return s.Inner.PersistState() 28 } 29 30 func (s *LockDisabled) Lock(info *LockInfo) (string, error) { 31 return "", nil 32 } 33 34 func (s *LockDisabled) Unlock(id string) error { 35 return nil 36 }