func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) { url, err := url.Parse(path) if err != nil { return nil, errors.Trace(err) } name := strings.ToLower(url.Scheme) d, ok := stores[name] if !ok { return nil, errors.Errorf("invalid uri format, storage %s is not registered", name) } var s kv.Storage util.RunWithRetry(maxRetries, retryInterval, func() (bool, error) { s, err = d.Open(path) return kv.IsRetryableError(err), err }) return s, errors.Trace(err) }
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) { key := store.UUID() dm.mu.Lock() defer dm.mu.Unlock() d = dm.domains[key] if d != nil { return } lease := time.Duration(0) if !localstore.IsLocalStore(store) { lease = schemaLease } err = util.RunWithRetry(defaultMaxRetries, retryInterval, func() (retry bool, err1 error) { d, err1 = domain.NewDomain(store, lease) return true, errors.Trace(err1) }) if err != nil { return nil, errors.Trace(err) } dm.domains[key] = d return }