// NewPoolDescriptor creates a new PoolDescriptor given a swarming hostname
// and a slice of dimensions.  The dimensions are expected to be in "key:value" format,
// where the key is the tag name.  This is the same format returned by the Swarming API.
769803
func NewPoolDescriptor(host string, dimensions []string) PoolDescriptor {
	desc := make([]string, 0, len(dimensions)+1)
	desc = append(desc, fmt.Sprintf("%s:%s", SwarmingHostnameKey, host))
	desc = append(desc, dimensions...)
	sort.Strings(desc)
	return desc
}
336299
func NewDefaultPoolConfig() *ObjectPoolConfig {
	return &ObjectPoolConfig{
		LIFO:                     DefaultLIFO,
		MaxTotal:                 DefaultMaxTotal,
		MaxIdle:                  DefaultMaxIdle,
		MinIdle:                  DefaultMinIdle,
		MinEvictableIdleTime:     DefaultMinEvictableIdleTime,
		SoftMinEvictableIdleTime: DefaultSoftMinEvictableIdleTime,
		NumTestsPerEvictionRun:   DefaultNumTestsPerEvictionRun,
		EvictionPolicyName:       DefaultEvictionPolicyName,
		EvitionContext:           context.Background(),
		TestOnCreate:             DefaultTestOnCreate,
		TestOnBorrow:             DefaultTestOnBorrow,
		TestOnReturn:             DefaultTestOnReturn,
		TestWhileIdle:            DefaultTestWhileIdle,
		TimeBetweenEvictionRuns:  DefaultTimeBetweenEvictionRuns,
		BlockWhenExhausted:       DefaultBlockWhenExhausted}
}
969560
func NewWriterPool(min, max int) *WriterPool {
	return &WriterPool{pool.New(min, max)}
}
827378
func NewPoolMetadata(dbfile string) (*PoolMetadata, error) {
	db, err := bolt.Open(dbfile, 0600, nil)
	if err != nil {
		return nil, err
	}

	metadata := &PoolMetadata{db: db}
	if err := metadata.ensureDatabaseInitialized(); err != nil {
		return nil, errors.Wrap(err, "failed to initialize database")
	}

	return metadata, nil
}
995491
func NewPool(ctx context.Context, dialOptions ...grpc.DialOption) *Pool {
	return &Pool{
		bgCtx:       ctx,
		dialOptions: dialOptions,
		conns:       make(map[string]*conn),
	}
}
698462
func NewPool(opts Options) Pool {
	p := &poolOfContexts{
		ctxPool: pool.NewObjectPool(opts.ContextPoolOptions()),
		finalizersPool: newFinalizeablesArrayPool(finalizeablesArrayPoolOpts{
			Capacity:    opts.InitPooledFinalizerCapacity(),
			MaxCapacity: opts.MaxPooledFinalizerCapacity(),
			Options:     opts.FinalizerPoolOptions(),
		}),
	}

	p.finalizersPool.Init()
	p.ctxPool.Init(func() interface{} {
		return newPooledContext(p)
	})

	return p
}
1256248
func NewPooledCloner(atl atlas.Atlas) PooledCloner {
	return PooledCloner{
		pool: sync.Pool{
			New: func() interface{} {
				return refmt.NewCloner(atl)
			},
		},
	}
}
1024238
func newPool(db *Database) *pool {
	p := &pool{
		database:    db,
		available:   make(map[*resp]*resp),
		inUse:       make(map[*resp]*resp),
		requestChan: make(chan *poolRequest),
	}
	p.backend = loop.Go(p.backendLoop, "redis", db.address, db.index)
	return p
}
32595
func (d PoolDescriptor) PoolID() string {
	s, err := json.Marshal(d)
	if err != nil {
		// This should never happen for a slice of strings.
		panic(err)
	}
	return fmt.Sprintf("%x", sha256.Sum256(s))
}
443331
func (c *Characteristic) AddDescriptor(u UUID) *Descriptor {
	for _, d := range c.descs {
		if d.uuid.Equal(u) {
			panic("service already contains a characteristic with uuid " + u.String())
		}
	}
	d := &Descriptor{uuid: u, char: c}
	c.descs = append(c.descs, d)
	return d
}
236155
func (cln *Client) ReadDescriptor(d *ble.Descriptor) ([]byte, error) {
	rsp := cln.conn.sendReq(77, xpc.Dict{
		"kCBMsgArgDeviceUUID":       cln.id,
		"kCBMsgArgDescriptorHandle": d.Handle,
	})
	if rsp.err() != nil {
		return nil, rsp.err()
	}
	return rsp.data(), nil
}
654266
func (p *Client) WriteDescriptor(d *ble.Descriptor, v []byte) error {
	p.Lock()
	defer p.Unlock()
	return p.ac.Write(d.Handle, v)
}
1270388
func (p *Client) ReadDescriptor(d *ble.Descriptor) ([]byte, error) {
	p.Lock()
	defer p.Unlock()
	return p.ac.Read(d.Handle)
}
796807
func NewWithDescriptor(descriptorsRoute string, docsRoute string, docslogLevel logrus.Level, requestTimeout ...time.Duration) *ProtoClient {
	newclient := newProto(docslogLevel, requestTimeout...)
	newclient.docsRoute = docsRoute
	newclient.descriptorsRoute = descriptorsRoute
	return newclient
}
1102726
func NewNewDecimalFieldDescriptor(nullable NullableColumn, metadata []byte) (
	fd FieldDescriptor,
	remaining []byte,
	err error) {

	if len(metadata) < 2 {
		return nil, nil, errors.New("Metadata has too few bytes")
	}

	return &newDecimalFieldDescriptor{
		baseFieldDescriptor: baseFieldDescriptor{
			fieldType:  mysql_proto.FieldType_NEWDECIMAL,
			isNullable: nullable,
		},

		precision: uint8(metadata[0]),
		decimals:  uint8(metadata[1]),
	}, metadata[2:], nil
}
18666
func NewDescriptor(u UUID, h uint16, char *Characteristic) *Descriptor {
	cd := &Descriptor{
		uuid: u,
		h:    h,
		char: char,
	}
	return cd
}
451048
func (s *Stackdriver) newListMetricDescriptorsFilters() []string {
	if len(s.MetricTypePrefixInclude) == 0 {
		return nil
	}

	metricTypeFilters := make([]string, len(s.MetricTypePrefixInclude))
	for i, metricTypePrefix := range s.MetricTypePrefixInclude {
		metricTypeFilters[i] = fmt.Sprintf(`metric.type = starts_with(%q)`, metricTypePrefix)
	}
	return metricTypeFilters
}