// NewStore returns an instance of Store.
549624
func NewStore(path string) *Store {
	return &Store{
		path:        path,
		data:        newRaftData(),
		subscribers: make(map[string]*list.List),

		leaderCh:   make(chan bool),
		heartbeats: make(map[instanceKey]time.Time),

		closing: make(chan struct{}),

		HeartbeatTimeout:   1000 * time.Millisecond,
		ElectionTimeout:    1000 * time.Millisecond,
		LeaderLeaseTimeout: 500 * time.Millisecond,
		CommitTimeout:      50 * time.Millisecond,

		InstanceTTL:         DefaultInstanceTTL,
		ExpiryCheckInterval: DefaultExpiryCheckInterval,

		LogOutput: os.Stderr,
		Now:       time.Now,
	}
}
232175
func newStoreManagerNoRun(backing Backing) *storeManager {
	return &storeManager{
		backing: backing,
		request: make(chan *request),
		all:     newStore(),
		waiting: make(map[*Multiwatcher]*request),
	}
}
80778
func NewStoreConfig() *StoreConfig {
	return &StoreConfig{
		Enabled:                  true,
		Addrs:                    "localhost",
		Keyspace:                 "metrictank",
		Consistency:              "one",
		HostSelectionPolicy:      "tokenaware,hostpool-epsilon-greedy",
		Timeout:                  "1s",
		ReadConcurrency:          20,
		WriteConcurrency:         10,
		ReadQueueSize:            200000,
		WriteQueueSize:           100000,
		Retries:                  0,
		WindowFactor:             20,
		OmitReadTimeout:          "60s",
		CqlProtocolVersion:       4,
		CreateKeyspace:           true,
		DisableInitialHostLookup: false,
		SSL:                      false,
		CaPath:                   "/etc/metrictank/ca.pem",
		HostVerification:         true,
		Auth:                     false,
		Username:                 "cassandra",
		Password:                 "cassandra",
		SchemaFile:               "/etc/metrictank/schema-store-cassandra.toml",
	}
}
527724
func NewSnapshotStore(
	dir string,
	retain int,
	logger Logger,
) (raft.SnapshotStore, error) {
	const logPrefix = "[snapshot] "
	if err := os.MkdirAll(dir, 0700); err != nil {
		return nil, errors.Trace(err)
	}
	logWriter := &raftutil.LoggoWriter{logger, loggo.DEBUG}
	logLogger := log.New(logWriter, logPrefix, 0)

	snaps, err := raft.NewFileSnapshotStoreWithLogger(dir, retain, logLogger)
	if err != nil {
		return nil, errors.Annotate(err, "failed to create file snapshot store")
	}
	return snaps, nil
}
444935
func (c *Cluster) StopStore(storeID uint64) {
	c.Lock()
	defer c.Unlock()

	if store := c.stores[storeID]; store != nil {
		store.meta.State = metapb.StoreState_Offline
	}
}
1143682
func newStore() *multiwatcherStore {
	return &multiwatcherStore{
		entities: make(map[interface{}]*list.Element),
		list:     list.New(),
	}
}
286043
func NewStorage(db *sql.DB) *Storage {
	dbconn.DB.AutoMigrate(&service.Client{})
	dbconn.DB.AutoMigrate(&service.Authorize{})
	dbconn.DB.AutoMigrate(&service.Access{})
	dbconn.DB.AutoMigrate(&service.Refresh{})
	return &Storage{db}
}
1239111
func (s *SQLStore) newSQLSubStore(channelID int64, limits *SubStoreLimits) *SQLSubStore {
	subStore := &SQLSubStore{
		sqlStore:  s,
		channelID: channelID,
		maxSubID:  &s.maxSubID,
		limits:    *limits,
	}
	subStore.log = s.log
	if s.opts.NoCaching {
		subStore.subLastSent = make(map[uint64]uint64)
	} else {
		subStore.cache = &sqlSubAcksPendingCache{
			subs: make(map[uint64]*sqlSubAcksPending),
		}
	}
	return subStore
}
987342
func NewStore(rootPath string, drivers *drivers.Store) (*VolumeStore, error) {
	vs := &VolumeStore{
		locks:   &locker.Locker{},
		names:   make(map[string]volume.Volume),
		refs:    make(map[string]map[string]struct{}),
		labels:  make(map[string]map[string]string),
		options: make(map[string]map[string]string),
		drivers: drivers,
	}

	if rootPath != "" {
		// initialize metadata store
		volPath := filepath.Join(rootPath, volumeDataDir)
		if err := os.MkdirAll(volPath, 0750); err != nil {
			return nil, err
		}

		var err error
		vs.db, err = bolt.Open(filepath.Join(volPath, "metadata.db"), 0600, &bolt.Options{Timeout: 1 * time.Second})
		if err != nil {
			return nil, errors.Wrap(err, "error while opening volume store metadata database")
		}

		// initialize volumes bucket
		if err := vs.db.Update(func(tx *bolt.Tx) error {
			if _, err := tx.CreateBucketIfNotExists(volumeBucketName); err != nil {
				return errors.Wrap(err, "error while setting up volume store metadata database")
			}
			return nil
		}); err != nil {
			return nil, err
		}
	}

	vs.restore()

	return vs, nil
}
1170251
func New(c *clientv3.Client, codec runtime.Codec, prefix string, transformer value.Transformer, pagingEnabled bool) storage.Interface {
	return newStore(c, pagingEnabled, codec, prefix, transformer)
}
10620
func NewCodeStore(idStore *IDStore, options CodeStoreOptions) (*CodeStore, error) {
	return newCodeStore(idStore, options)
}
240239
func NewStoreWithVars(vars map[string]string) types.Store {
	m := map[string]interface{}{}
	for k, v := range vars {
		m[k] = v
	}
	return newKeyValueStore(m, -1, false)
}
1300108
func NewStorage(ctx context.Context, id StorageBackend, url *URL) (Storage, error) {
	if be, found := storageRegistry[id]; found {
		return be.New(ctx, url)
	}
	return nil, errors.Wrapf(ErrNotFound, "unknown backend: %s", url.String())
}
78149
func NewStorage(modelUUID string, session *mgo.Session) Storage {
	return stateStorage{modelUUID, session}
}
252423
func SetStore(c context.Context, s store.Store) {
	GetState(c).SetStore(s)
}
722303
func NewStore(robot *Robot) (Store, error) {
	name := Config.StoreName
	if _, ok := Stores[name]; !ok {
		return nil, fmt.Errorf("%s is not a registered store", Config.StoreName)
	}

	store, err := Stores[name].newFunc(robot)
	if err != nil {
		return nil, err
	}
	return store, nil
}
382034
func (m *resolversMap) LoadOrStore(key string, value resolver.Resolver) (resolver.Resolver, bool) {
	i, _ := m.data.LoadOrStore(key, value)
	s, ok := i.(resolver.Resolver)
	return s, ok
}