// New creates/opens a named bucket.
491202
func (db *DB) New(name []byte) (*Bucket, error) {
	err := db.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists(name)
		if err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	return &Bucket{db, name}, nil
}
37325
func (factory *PrometheusBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := PrometheusBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
1062883
func (c *BucketConfiguration) NewBucket() Bucket {
	return Bucket{
		Capacity: c.Capacity,
		Count:    c.Count,
	}
}
449448
func (factory *HTTPBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := HTTPBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
521922
func New(size, count int) *Pool {
	return NewEndian(size, count, binary.BigEndian)
}
859909
func New(bdb *bolt.DB) *DB {
	return &DB{
		rootBuckets: make(map[string]*bucketMeta),
		bdb:         bdb,
	}
}
841001
func New(files Files) (vfs.FileSystem, error) {
	fs := make(MapFS)

	for path, file := range files {
		if err := fs.addFile(path, file); err != nil {
			return nil, err
		}
	}

	return fs, nil
}
395914
func NewBucket() *Bucket {
	bkt := new(Bucket)

	bkt.Weight = 0
	bkt.pad = make([]byte, 4)
	bkt.Actions = make([]Action, 0)
	bkt.WatchPort = P_ANY
	bkt.WatchGroup = OFPG_ANY
	bkt.Length = bkt.Len()

	return bkt
}
964196
func New(store *store.MemoryStore, pg plugingetter.PluginGetter, netConfig *cnmallocator.NetworkConfig) (*Allocator, error) {
	a := &Allocator{
		store: store,
		taskBallot: &taskBallot{
			votes: make(map[string][]string),
		},
		stopChan:      make(chan struct{}),
		doneChan:      make(chan struct{}),
		pluginGetter:  pg,
		networkConfig: netConfig,
	}

	return a, nil
}
110348
func New(minSize, maxSize int) *Pool {
	if maxSize < minSize {
		panic("maxSize can't be less than minSize")
	}
	const multiplier = 2
	var pools []*sizedPool
	curSize := minSize
	for curSize < maxSize {
		pools = append(pools, newSizedPool(curSize))
		curSize *= multiplier
	}
	pools = append(pools, newSizedPool(maxSize))
	return &Pool{
		minSize: minSize,
		maxSize: maxSize,
		pools:   pools,
	}
}
893574
func (factory *HueBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := HueBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
1185365
func New(settings SettingsManager, registry storage.ProviderRegistry) PoolManager {
	return &poolManager{settings, registry}
}
1235390
func (s *Storage) Create(name string, capacity uint, rate time.Duration) (leakybucket.Bucket, error) {
	conn := s.pool.Get()
	defer conn.Close()

	if count, err := redis.Uint64(conn.Do("GET", name)); err != nil {
		if err != redis.ErrNil {
			return nil, err
		}
		// return a standard bucket if key was not found
		return &bucket{
			name:      name,
			capacity:  capacity,
			remaining: capacity,
			reset:     time.Now().Add(rate),
			rate:      rate,
			pool:      s.pool,
		}, nil
	} else if ttl, err := redis.Int64(conn.Do("PTTL", name)); err != nil {
		return nil, err
	} else {
		b := &bucket{
			name:      name,
			capacity:  capacity,
			remaining: capacity - min(capacity, uint(count)),
			reset:     time.Now().Add(time.Duration(ttl * millisecond)),
			rate:      rate,
			pool:      s.pool,
		}
		return b, nil
	}
}
1315623
func New(bucket string, service S3API) S3Store {
	return S3Store{
		Bucket:            bucket,
		Service:           service,
		MaxPartSize:       5 * 1024 * 1024 * 1024,
		MinPartSize:       5 * 1024 * 1024,
		MaxMultipartParts: 10000,
		MaxObjectSize:     5 * 1024 * 1024 * 1024 * 1024,
	}
}
550812
func (api *SimpleMonitorAPI) New(target string) *sacloud.SimpleMonitor {
	return sacloud.CreateNewSimpleMonitor(target)
}
1300274
func New(o Options) (storage.Storage, error) {
	s := storageImpl{
		Options: &o,
	}

	if !s.Stream.IsFullPath() {
		return nil, fmt.Errorf("invalid stream URL: %q", s.Stream)
	}
	if s.Index != "" && !s.Index.IsFullPath() {
		return nil, fmt.Errorf("invalid index URL: %v", s.Index)
	}

	return &s, nil
}
1156995
func New(b *Bucketer) *Distribution {
	if b == nil {
		b = DefaultBucketer
	}
	return &Distribution{b: b, lastNonZeroBucket: -1}
}