From 88d22e62d207f06eeb26e3208ca31825b5694b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= Date: Fri, 27 Nov 2015 00:30:37 +0000 Subject: [PATCH] Updating code to reflect changes in chainstore. --- Glockfile | 2 +- server/bucket.go | 9 +++------ server/config.go | 26 +++++++++++--------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Glockfile b/Glockfile index f8f345f..8faf1ff 100644 --- a/Glockfile +++ b/Glockfile @@ -13,7 +13,7 @@ github.com/goware/urlx 6292537e62efc11517f237ed166bd105c6b44aa8 github.com/mitchellh/goamz caaaea8b30ee15616494ee68abd5d8ebbbef05cf github.com/opennota/urlesc 5fa9ff0392746aeae1c4b37fcc42c65afa7a9587 github.com/pmezard/go-difflib d8ed2627bdf02c080bf22230dbb337003b7aba2d -github.com/pressly/chainstore 907f0f81699a835e86a81f11a3d3cd4d7215c360 +github.com/pressly/chainstore 63215bf46a6b470683ec038aea7e503281af5647 github.com/pressly/chi 9c95d30f0c46f408acf781e52ecf6a15c2323a15 github.com/pressly/consistentrd 43f3d1020fc03cf1271313ec9b95c8a967c0b878 github.com/rs/cors eb527c8097e0f19a3ff7b253a3fe70545070f420 diff --git a/server/bucket.go b/server/bucket.go index 6c53759..3e48ee3 100644 --- a/server/bucket.go +++ b/server/bucket.go @@ -163,8 +163,7 @@ func (b *Bucket) DbFindImage(ctx context.Context, key string, optSizing ...*imgr return nil, ErrImageNotFound } - // data, err := app.Chainstore.Get(context.Background(), idxKey) // TODO - data, err := app.Chainstore.Get(idxKey) // TODO + data, err := app.Chainstore.Get(context.Background(), idxKey) if err != nil { return nil, err } @@ -186,8 +185,7 @@ func (b *Bucket) DbSaveImage(ctx context.Context, im *Image, sizing *imgry.Sizin idxKey := b.DbIndexKey(im.Key, sizing) - // err = app.Chainstore.Put(context.Background(), idxKey, im.Data) // TODO - err = app.Chainstore.Put(idxKey, im.Data) + err = app.Chainstore.Put(context.Background(), idxKey, im.Data) if err != nil { return } @@ -204,8 +202,7 @@ func (b *Bucket) DbDelImage(ctx context.Context, key string) (err error) { return } - // err = app.Chainstore.Del(context.Background(), idxKey) // + "*") // TODO - err = app.Chainstore.Del(idxKey) + err = app.Chainstore.Del(context.Background(), idxKey) return } diff --git a/server/config.go b/server/config.go index 77bee07..153298a 100644 --- a/server/config.go +++ b/server/config.go @@ -16,6 +16,7 @@ import ( "github.com/pressly/chainstore/boltstore" "github.com/pressly/chainstore/lrumgr" "github.com/pressly/chainstore/memstore" + "github.com/pressly/chainstore/metricsmgr" "github.com/pressly/chainstore/s3store" ) @@ -191,27 +192,22 @@ func (cf *Config) GetChainstore() (chainstore.Store, error) { // the bolt data.. // Build the stores and setup the chain - // memStore := metricsmgr.New("fn.store.mem", nil, - // memstore.New(cf.Chainstore.MemCacheSize*1024*1024), - // ) - memStore := memstore.New(cf.Chainstore.MemCacheSize * 1024 * 1024) - - // diskStore := lrumgr.New(cf.Chainstore.DiskCacheSize*1024*1024, - // metricsmgr.New("fn.store.bolt", nil, - // boltstore.New(cf.Chainstore.Path+"store.db", "imgry"), - // ), - // ) + memStore := metricsmgr.New("fn.store.mem", + memstore.New(cf.Chainstore.MemCacheSize*1024*1024), + ) + diskStore := lrumgr.New(cf.Chainstore.DiskCacheSize*1024*1024, - boltstore.New(cf.Chainstore.Path+"store.db", "imgry"), + metricsmgr.New("fn.store.bolt", + boltstore.New(cf.Chainstore.Path+"store.db", "imgry"), + ), ) var store chainstore.Store if cf.Chainstore.S3AccessKey != "" && cf.Chainstore.S3SecretKey != "" { - // s3Store := metricsmgr.New("fn.store.s3", nil, - // s3store.New(cf.Chainstore.S3Bucket, cf.Chainstore.S3AccessKey, cf.Chainstore.S3SecretKey), - // ) - s3Store := s3store.New(cf.Chainstore.S3Bucket, cf.Chainstore.S3AccessKey, cf.Chainstore.S3SecretKey) + s3Store := metricsmgr.New("fn.store.s3", + s3store.New(cf.Chainstore.S3Bucket, cf.Chainstore.S3AccessKey, cf.Chainstore.S3SecretKey), + ) // store = chainstore.New(memStore, chainstore.Async(diskStore, s3Store)) store = chainstore.New(memStore, chainstore.Async(s3Store))