func (p *LevelDBPersister) Close() {
	p.db.Close()
}
Close the persister
package dagger
import (
	"encoding/json"
	"fmt"
	log "github.com/Sirupsen/logrus"
	"path"
	"github.com/syndtr/goleveldb/leveldb"
	"github.com/syndtr/goleveldb/leveldb/opt"
	"github.com/syndtr/goleveldb/leveldb/util"
	"github.com/twinj/uuid"
)
const (
	receivedKeyFormat    = "%s-r-%s"     
	productionsKeyFormat = "%s-p-%d-%s"  
	inKeyFormat          = "%s-i-%d-%s"  
)
type PersisterConfig struct {
	Dir string
}
func defaultPersisterConfig() *PersisterConfig {
	return &PersisterConfig{
		Dir: "/tmp/dagger",
	}
}
type Persister interface {
	Close()
	TaskPersister
	StreamBuffer
	SentTracker
	ReceivedTracker
}
type TaskPersister interface {
	CommitComputation(compID StreamID, in *Record, out []*Record) error
	GetLastTimestamp(compID StreamID) (Timestamp, error)
	GetSnapshot(compID StreamID) ([]byte, error)
	ApplySnapshot(compID StreamID, snapshot []byte) error
}
type StreamBuffer interface {
	Insert(compID StreamID, bufID string, t *Record) error
	ReadBuffer(compID StreamID, bufID string, from Timestamp, to Timestamp, recCh chan<- *Record, errc chan<- error, readCompleted chan struct{})
}
type SentTracker interface {
	SentSuccessfuly(StreamID, *Record) error
}
type MultiSentTracker struct {
	trackers []SentTracker
}
func (st MultiSentTracker) SentSuccessfuly(compID StreamID, t *Record) error {
	for _, tracker := range st.trackers {
		err := tracker.SentSuccessfuly(compID, t)
		if err != nil {
			return err
		}
	}
	return nil
}
type ReceivedTracker interface {
	PersistReceivedRecords(StreamID, []*Record) error
	GetRecentReceived(StreamID) ([]string, error)
	ReceivedAlready(StreamID, *Record) (bool, error)
}
func NewPersister(customizeConfig func(*PersisterConfig)) (Persister, error) {
	conf := defaultPersisterConfig()
	if customizeConfig != nil {
		customizeConfig(conf)
	}
	filename := path.Join(conf.Dir, "daggerDB-"+uuid.NewV4().String())
	db, err := leveldb.OpenFile(filename, nil)
	if err != nil {
		return nil, err
	}
	return &LevelDBPersister{db, filename}, nil
}
type LevelDBPersister struct {
	db       *leveldb.DB
	filename string
}