// NewPooledObjectFactorySimple return a DefaultPooledObjectFactory, only custom MakeObject func
968967
func NewPooledObjectFactorySimple(
	create func(context.Context) (interface{}, error)) PooledObjectFactory {
	return NewPooledObjectFactory(create, nil, nil, nil, nil)
}
833593
func (l *LocalStore) NewObject(objectname string) (cloudstorage.Object, error) {
	obj, err := l.Get(context.Background(), objectname)
	if err != nil && err != cloudstorage.ErrObjectNotFound {
		return nil, err
	} else if obj != nil {
		return nil, cloudstorage.ErrObjectExists
	}

	of := path.Join(l.storepath, objectname)
	err = cloudstorage.EnsureDir(of)
	if err != nil {
		return nil, err
	}

	cf := cloudstorage.CachePathObj(l.cachepath, objectname, l.Id)

	return &object{
		name:      objectname,
		storepath: of,
		cachepath: cf,
	}, nil
}
595571
func NewFromPool(p *sync.Pool) *Container {
	res := new(Container)
	res.pool = p
	return res
}
1290266
func NewChannelPool(poolConfig *Config) (Pool, error) {
	if poolConfig.InitialCap < 0 || poolConfig.MaxCap <= 0 || poolConfig.InitialCap > poolConfig.MaxCap {
		return nil, errors.New("invalid capacity settings")
	}
	if poolConfig.Factory == nil {
		return nil, errors.New("invalid factory func settings")
	}
	if poolConfig.Close == nil {
		return nil, errors.New("invalid close func settings")
	}

	c := &channelPool{
		conns:       make(chan *idleConn, poolConfig.MaxCap),
		factory:     poolConfig.Factory,
		close:       poolConfig.Close,
		idleTimeout: poolConfig.IdleTimeout,
	}

	if poolConfig.Ping != nil {
		c.ping = poolConfig.Ping
	}

	for i := 0; i < poolConfig.InitialCap; i++ {
		conn, err := c.factory()
		if err != nil {
			c.Release()
			return nil, fmt.Errorf("factory is not able to fill the pool: %s", err)
		}
		c.conns <- &idleConn{conn: conn, t: time.Now()}
	}

	return c, nil
}
1359648
func (g *GcsFS) NewObject(objectname string) (cloudstorage.Object, error) {
	obj, err := g.Get(context.Background(), objectname)
	if err != nil && err != cloudstorage.ErrObjectNotFound {
		return nil, err
	} else if obj != nil {
		return nil, cloudstorage.ErrObjectExists
	}

	cf := cloudstorage.CachePathObj(g.cachepath, objectname, g.Id)

	return &object{
		name:       objectname,
		metadata:   map[string]string{cloudstorage.ContentTypeKey: cloudstorage.ContentType(objectname)},
		gcsb:       g.gcsb(),
		bucket:     g.bucket,
		cachedcopy: nil,
		cachepath:  cf,
	}, nil
}
250741
func NewFloatsPool(sizes []Bucket, opts ObjectPoolOptions) FloatsPool {
	return &floatsPool{pool: NewBucketizedObjectPool(sizes, opts)}
}
857307
func NewObjectStorage(dir *dotgit.DotGit, objectCache cache.Object) *ObjectStorage {
	return NewObjectStorageWithOptions(dir, objectCache, Options{})
}
709719
func newBaseConnectionPool(
	options ConnectionOptions,
	createPool func(rp.Options) rp.ResourcePool) ConnectionPool {

	dial := options.Dial
	if dial == nil {
		dial = defaultDialFunc
	}

	openFunc := func(loc string) (interface{}, error) {
		network, address := parseResourceLocation(loc)
		return dial(network, address)
	}

	closeFunc := func(handle interface{}) error {
		return handle.(net.Conn).Close()
	}

	poolOptions := rp.Options{
		MaxActiveHandles:   options.MaxActiveConnections,
		MaxIdleHandles:     options.MaxIdleConnections,
		MaxIdleTime:        options.MaxIdleTime,
		OpenMaxConcurrency: options.DialMaxConcurrency,
		Open:               openFunc,
		Close:              closeFunc,
		NowFunc:            options.NowFunc,
	}

	return &connectionPoolImpl{
		options: options,
		pool:    createPool(poolOptions),
	}
}
609791
func NewPool(
	bytesPool pool.CheckedBytesPool,
	opts PoolOptions,
) Pool {
	opts = opts.defaultsIfNotSet()

	p := &simplePool{
		bytesPool: bytesPool,
		pool:      pool.NewObjectPool(opts.IDPoolOptions),
		tagArrayPool: newTagArrayPool(tagArrayPoolOpts{
			Options:     opts.TagsPoolOptions,
			Capacity:    opts.TagsCapacity,
			MaxCapacity: opts.TagsMaxCapacity,
		}),
		itersPool: pool.NewObjectPool(opts.TagsIteratorPoolOptions),
	}
	p.pool.Init(func() interface{} {
		return &id{pool: p}
	})
	p.tagArrayPool.Init()
	p.itersPool.Init(func() interface{} {
		return newTagSliceIter(Tags{}, p)
	})

	return p
}
810727
func NewObserverFactory(config Config) (observer.ObserverFactory, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Annotate(err, "validating config")
	}

	// Observer is currently stateless, so we return the same one for each
	// API connection. Individual RPC requests still get their own RPC
	// observers.
	o := &Observer{
		clock: config.Clock,
		metrics: metrics{
			apiRequestDuration:           config.MetricsCollector.APIRequestDuration(),
			deprecatedAPIRequestsTotal:   config.MetricsCollector.DeprecatedAPIRequestsTotal(),
			deprecatedAPIRequestDuration: config.MetricsCollector.DeprecatedAPIRequestDuration(),
		},
	}
	return func() observer.Observer {
		return o
	}, nil
}
939005
func NewPool(config Config) *ConnectionPool {
	p := &ConnectionPool{
		Config: config,
		pool:   make(chan *Connection, config.Size),
	}
	return p
}
764958
func NewPool(capacity int, itemFactory ItemFactory) (Pool, error) {

	q, err := queue.NewChannelQueue(capacity)
	if err != nil {
		return nil, err
	}

	itemMap := make(map[uint64]*Item)
	pool := itemPool{itemMap: itemMap, itemQ: q, capacity: capacity, itemFactory: itemFactory}
	return &pool, nil
}
700515
func NewFloatSimple(f float64) FloatAttribute {
	result := &FloatSimple{
		NewAttribute(NORMAL, nil, nil),
	}
	result.Set(f)
	return result
}
63083
func NewFactory() *factory.KustFactory {
	return factory.NewKustFactory(
		kunstruct.NewKunstructuredFactoryImpl(),
		validator.NewKustValidator(),
		transformer.NewFactoryImpl(),
	)
}
392313
func NewIdentityProviderFactory(context servicecontext.ServiceContext) service.IdentityProviderFactory {
	factory := &identityProviderFactoryImpl{
		BaseService: base.NewBaseService(context),
	}
	return factory
}
883602
func (f *DefaultPooledObjectFactory) MakeObject(ctx context.Context) (*PooledObject, error) {
	return f.make(ctx)
}
532081
func NewObject(id string, resourceType string, attributes interface{}) (*Object, *Error) {
	object := &Object{
		ID:            id,
		Type:          resourceType,
		Links:         map[string]*Link{},
		Relationships: map[string]*Relationship{},
	}

	rawJSON, err := json.MarshalIndent(attributes, "", " ")
	if err != nil {
		return nil, ISE(fmt.Sprintf("Error marshaling attrs while creating a new JSON Object: %s", err))
	}

	object.Attributes = rawJSON
	return object, nil
}