func NewTestBackend(t *testing.T) (string, backend.Backend) { tmpPath, err := ioutil.TempDir("", "lease") if err != nil { t.Fatalf("failed to create tmpdir (%v)", err) } return tmpPath, backend.New(path.Join(tmpPath, "be"), time.Second, 10000) }
func NewStore(path string, bachInterval time.Duration, batchLimit int) KV { s := &store{ b: backend.New(path, batchInterval, batchLimit), kvindex: newTreeIndex(), currentRev: revision{}, compactMainRev: -1, stopc: make(chan struct{}), } tx := s.b.BatchTx() tx.Lock() tx.UnsafeCreateBucket(keyBucketName) tx.UnsafeCreateBucket(metaBucketName) tx.Unlock() s.b.ForceCommit() return s }
func initStorage() { be := backend.New("storage-bench", time.Duration(batchInterval), batchLimit) s = storage.NewStore(be, &lease.FakeLessor{}) os.Remove("storage-bench") // boltDB has an opened fd, so removing the file is ok }