Example #1
0
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)
}
Example #2
0
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
}
Example #3
0
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
}