Exemplo n.º 1
0
func (c *Client) boltFile(app string) string {
	if used, err := c.Used(); err == nil && app != "konfig" {
		return filepath.Join(config.KodingHome(), app+"."+used.ID()+".bolt")
	}
	return filepath.Join(config.KodingHome(), app+".bolt")
}
Exemplo n.º 2
0
func (c *Client) home() string {
	if c.Home != "" {
		return c.Home
	}
	return config.KodingHome()
}
Exemplo n.º 3
0
	"os"
	"path/filepath"
	"strings"
	"sync"
	"time"

	"koding/kites/config"
	"koding/kites/kloud/utils/object"
	"koding/klient/storage"
	"koding/tools/util"

	"github.com/boltdb/bolt"
)

var defaultCacheOpts = &config.CacheOptions{
	File: filepath.Join(config.KodingHome(), "konfig.bolt"),
	BoltDB: &bolt.Options{
		Timeout: 5 * time.Second,
	},
	Bucket: []byte("konfig"),
}

var DefaultClient = &Client{}

type Client struct {
	Cache     *config.Cache        // if nil, a new db will be opened during each operation
	CacheOpts *config.CacheOptions // if nil, defaultCacheOpts are going to be used
	Home      string               // uses config.KodingHome by default
	Owner     *config.User         // uses config.CurrentUser by default

	once sync.Once // for c.init()