Пример #1
0
// Attach handlers that provide the Database API
func storeHandle(factory chunks.Factory, hndlr datas.Handler) httprouter.Handle {
	return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
		cs := factory.CreateStore(params.ByName(dbParam))
		defer cs.Close()
		hndlr(w, req, params, cs)
	}
}
Пример #2
0
func main() {
	chunks.RegisterLevelDBFlags()
	dynFlags := chunks.DynamoFlags("")

	flag.Usage = usage
	flag.Parse()

	if *portFlag == 0 || *authKeyFlag == "" {
		usage()
		return
	}

	var factory chunks.Factory
	if factory = dynFlags.CreateFactory(); factory != nil {
		fmt.Printf("Using dynamo ...\n")
	} else if *ldbDir != "" {
		factory = chunks.NewLevelDBStoreFactoryUseFlags(*ldbDir)
		fmt.Printf("Using leveldb ...\n")
	} else {
		factory = chunks.NewMemoryStoreFactory()
		fmt.Printf("Using mem ...\n")
	}
	defer factory.Shutter()

	startWebServer(factory, *authKeyFlag)
}