// New gives us a new Store based on "github.com/coreos/bbolt"
765484
func New(db *bolt.DB, rootBucket string, opts ...Option) (*Store, error) {
	if db.IsReadOnly() {
		return nil, ErrDBReadOnly
	}
	bucket := []byte(rootBucket)

	err := db.Update(func(tx *bolt.Tx) error {
		// create root
		root, err := tx.CreateBucketIfNotExists(bucket)
		if err != nil {
			return err
		}
		// create the buckets inside the root
		for _, b := range [][]byte{
			tasksPath, orgsPath, taskMetaPath,
			orgByTaskID, nameByTaskID, runIDs,
		} {
			_, err := root.CreateBucketIfNotExists(b)
			if err != nil {
				return err
			}
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	st := &Store{db: db, bucket: bucket, idGen: snowflake.NewDefaultIDGenerator(), minLatestCompleted: math.MinInt64}
	for _, opt := range opts {
		opt(st)
	}
	return st, nil
}
168398
func New(key string, backends *stripe.Backends) *API {
	api := API{}
	api.Init(key, backends)
	return &api
}
9449
func New(s store.Store, ctx context.Context) (watcher.Watcher, error) {
	ret := &ContainerWatcher{
		invertsTable: make(map[string]string),
	}
	base, err := watcher.New(s, ctx, KEY, ret.convert, ret.invertKey)
	if err != nil {
		return nil, err
	}
	ret.BaseWatcher = *base
	return ret, nil
}
238569
func New() storage.Store {
	return &store{
		data:     map[string]interface{}{},
		triggers: map[*handle]storage.TriggerConfig{},
		policies: map[string][]byte{},
		indices:  newIndices(),
	}
}
712575
func New(c *Configuration) (b *Bundler, err error) {
	// Init
	b = &Bundler{
		appName:           c.AppName,
		bindPackage:       c.Bind.Package,
		Client:            &http.Client{},
		environments:      c.Environments,
		darwinAgentApp:    c.DarwinAgentApp,
		resourcesAdapters: c.ResourcesAdapters,
		ldflags:           c.LDFlags,
		infoPlist:         c.InfoPlist,
	}

	// Ldflags
	if b.ldflags == nil {
		b.ldflags = make(LDFlags)
	}

	// Add context
	b.ctx, b.cancel = context.WithCancel(context.Background())

	// Loop through environments
	for _, env := range b.environments {
		// Validate OS
		if !astilectron.IsValidOS(env.OS) {
			err = fmt.Errorf("OS %s is invalid", env.OS)
			return
		}
	}

	// Astilectron path
	if b.pathAstilectron, err = absPath(c.AstilectronPath, nil); err != nil {
		return
	}

	// Working directory path
	if b.pathWorkingDirectory, err = absPath(c.WorkingDirectoryPath, func() (string, error) { return filepath.Join(os.TempDir(), "astibundler"), nil }); err != nil {
		return
	}

	// Paths that depend on the working directory path
	b.pathBindInput = filepath.Join(b.pathWorkingDirectory, "bind")
	b.pathCache = filepath.Join(b.pathWorkingDirectory, "cache")

	// Darwin icon path
	if b.pathIconDarwin, err = absPath(c.IconPathDarwin, nil); err != nil {
		return
	}

	// Linux icon path
	if b.pathIconLinux, err = absPath(c.IconPathLinux, nil); err != nil {
		return
	}

	// Windows icon path
	if b.pathIconWindows, err = absPath(c.IconPathWindows, nil); err != nil {
		return
	}

	// Windows application manifest path
	if b.pathManifest, err = absPath(c.ManifestPath, nil); err != nil {
		return
	}

	// Input path
	if b.pathInput, err = absPath(c.InputPath, os.Getwd); err != nil {
		return
	}

	// Paths that depends on the input path
	for _, i := range filepath.SplitList(os.Getenv("GOPATH")) {
		var p = filepath.Join(i, "src")
		if strings.HasPrefix(b.pathInput, p) {
			b.pathBuild = strings.TrimPrefix(strings.TrimPrefix(b.pathInput, p), string(os.PathSeparator))
			break
		}
	}

	// Bind output path
	if b.pathBindOutput, err = absPath(c.Bind.OutputPath, func() (string, error) { return b.pathInput, nil }); err != nil {
		return
	}

	// If build path is empty, ldflags are not set properly
	if len(b.pathBuild) == 0 {
		b.pathBuild = "."
	}

	// Resources path
	if b.pathResources = c.ResourcesPath; len(b.pathResources) == 0 {
		b.pathResources = "resources"
	}

	// Vendor path
	if b.pathVendor = c.VendorDirPath; len(b.pathVendor) == 0 {
		b.pathVendor = vendorDirectoryName
	}
	b.pathVendor = filepath.Join(b.pathBindInput, b.pathVendor)

	// Go binary path
	b.pathGoBinary = "go"
	if len(c.GoBinaryPath) > 0 {
		b.pathGoBinary = c.GoBinaryPath
	}

	// Output path
	if b.pathOutput, err = absPath(c.OutputPath, func() (string, error) {
		p, err := os.Getwd()
		if err != nil {
			return "", err
		}
		p = filepath.Join(p, "output")
		return p, err
	}); err != nil {
		return
	}

	// Bind package
	if len(b.bindPackage) == 0 {
		b.bindPackage = "main"
	}
	return
}
195782
func New(store session.Store, maxAttempts int) session.Store {
	if maxAttempts <= 0 {
		maxAttempts = 3
	}
	return &retryStore{
		store:       store,
		maxAttempts: maxAttempts,
	}
}
672372
func New(bus embd.I2CBus) *BMP180 {
	return &BMP180{Bus: bus, Poll: pollDelay}
}
366978
func New(ctx context.Context, cfg *config.GCSCli) (*GCSBlobstore, error) {
	if cfg == nil {
		return nil, errors.New("expected non-nill config object")
	}

	authenticatedGCS, publicGCS, err := newStorageClients(ctx, cfg)
	if err != nil {
		return nil, fmt.Errorf("creating storage client: %v", err)
	}

	return &GCSBlobstore{authenticatedGCS: authenticatedGCS, publicGCS: publicGCS, config: cfg}, nil
}
278548
func New() Store {
	s := Store{m: make(map[string]KVPair)}
	s.FuncMap = map[string]interface{}{
		"exists": s.Exists,
		"ls":     s.List,
		"lsdir":  s.ListDir,
		"get":    s.Get,
		"gets":   s.GetAll,
		"getv":   s.GetValue,
		"getvs":  s.GetAllValues,
	}
	return s
}
77748
func New(db walletdb.DB, params chaincfg.Params) (*FilterStore, error) {
	err := walletdb.Update(db, func(tx walletdb.ReadWriteTx) error {
		// As part of our initial setup, we'll try to create the top
		// level filter bucket. If this already exists, then we can
		// exit early.
		filters, err := tx.CreateTopLevelBucket(filterBucket)
		if err != nil {
			return err
		}

		// If the main bucket doesn't already exist, then we'll need to
		// create the sub-buckets, and also initialize them with the
		// genesis filters.
		genesisBlock := params.GenesisBlock
		genesisHash := params.GenesisHash

		// First we'll create the bucket for the regular filters.
		regFilters, err := filters.CreateBucketIfNotExists(regBucket)
		if err != nil {
			return err
		}

		// With the bucket created, we'll now construct the initial
		// basic genesis filter and store it within the database.
		basicFilter, err := builder.BuildBasicFilter(genesisBlock, nil)
		if err != nil {
			return err
		}

		return putFilter(regFilters, genesisHash, basicFilter)
	})
	if err != nil && err != walletdb.ErrBucketExists {
		return nil, err
	}

	return &FilterStore{
		db: db,
	}, nil
}
884785
func (l loader) New(ctx context.Context, url *backend.URL) (backend.Storage, error) {
	be := New(url.Path)
	out.Debug(ctx, "Using Storage Backend: %s", be.String())
	return be, nil
}
663880
func (factory *IrcBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := IrcBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
243450
func New(params *stripe.SKUParams) (*stripe.SKU, error) {
	return getC().New(params)
}
341665
func New(s store.Store, ctx context.Context, key string, convert ConvertFunc, ckey2skey func(string) string) (*BaseWatcher, error) {
	watcher := &BaseWatcher{
		key:       key,
		convert:   convert,
		ckey2skey: ckey2skey,
		Store:     s,
		Ctx:       ctx,
		Sender:    NewSender(nil),
	}
	go watcher.watchStore(key)
	return watcher, nil
}
859909
func New(bdb *bolt.DB) *DB {
	return &DB{
		rootBuckets: make(map[string]*bucketMeta),
		bdb:         bdb,
	}
}
109813
func New(path string, mapping mapping.IndexMapping) (Index, error) {
	return newIndexUsing(path, mapping, Config.DefaultIndexType, Config.DefaultKVStore, nil)
}
679867
func (factory *PushoverBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := PushoverBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}