- defer可以在mutex lock之后,unlock
type MetaDb struct {
consul *gokit.Consul
identifier CloudIdentifier
mutex *sync.RWMutex
set *DbSet
}
func (m *MetaDb) Region() Region {
m.mutex.RLock()
defer m.mutex.RUnlock()
return m.set.Region
}