Пример #1
0
func CreateStore(t *testing.T) cloudstorage.Store {

	cloudstorage.LogConstructor = func(prefix string) logging.Logger {
		return logging.NewStdLogger(true, logging.DEBUG, prefix)
		//return testutils.NewStdLogger(t, prefix)
	}

	var config *cloudstorage.CloudStoreContext
	if os.Getenv("TESTINT") == "" {
		//os.RemoveAll("/tmp/mockcloud")
		//os.RemoveAll("/tmp/localcache")
		config = localconfig
	} else {
		config = gcsIntconfig
	}
	store, err := cloudstorage.NewStore(config)
	AssertEq(t, nil, err, "error.")

	return store
}
Пример #2
0
	"path/filepath"
	"strings"

	"github.com/lytics/cloudstorage/logging"
	"golang.org/x/net/context"
	"google.golang.org/cloud"
	"google.golang.org/cloud/storage"
)

const StoreCacheFileExt = ".cache"

var ObjectNotFound = fmt.Errorf("object not found")
var ObjectExists = fmt.Errorf("object already exists in backing store (use store.Get)")

var LogConstructor = func(prefix string) logging.Logger {
	return logging.NewStdLogger(true, logging.DEBUG, prefix)
}

//maxResults default number of objects to retrieve during a list-objects request,
// if more objects exist, then they will need to be paged
const maxResults = 3000

func NewStore(csctx *CloudStoreContext) (Store, error) {

	if csctx.PageSize == 0 {
		csctx.PageSize = maxResults
	}

	if csctx.TmpDir == "" {
		csctx.TmpDir = os.TempDir()
	}