Exemple #1
0
func New(stores []store.Store) (*Handler, error) {
	handlers := make([]*storehttp.Server, len(stores))
	for i, st := range stores {
		handlers[i] = storehttp.NewServer(st)
	}

	h := &Handler{
		stores:   stores,
		handlers: handlers,
	}

	return h, nil
}
Exemple #2
0
func New(db kvl.DB, scrubbers int, cacheSize int) (*Handler, error) {
	finder, err := multi.NewFinder(db)
	if err != nil {
		return nil, err
	}

	multi, err := multi.NewMulti(db, finder, scrubbers)
	if err != nil {
		finder.Stop()
		return nil, err
	}

	var dataStore store.Store = multi
	if cacheSize > 0 {
		dataStore = cache.New(cacheSize, multi)
	}

	return &Handler{
		db:         db,
		dataServer: storehttp.NewServer(dataStore),
		multi:      multi,
		finder:     finder,
	}, nil
}