// NewRootScope creates a new tally.Scope based on a tally.CachedStatsReporter
// based on the the the config.
326067
func (mc *MetricsConfiguration) NewRootScope() (tally.Scope, io.Closer, error) {
	var reporters []tally.CachedStatsReporter
	if mc.M3Reporter != nil {
		r, err := mc.M3Reporter.NewReporter()
		if err != nil {
			return nil, nil, err
		}
		reporters = append(reporters, r)
	}
	if mc.PrometheusReporter != nil {
		var opts prometheus.ConfigurationOptions
		r, err := mc.PrometheusReporter.NewReporter(opts)
		if err != nil {
			return nil, nil, err
		}
		reporters = append(reporters, r)
	}
	if len(reporters) == 0 {
		return nil, nil, errNoReporterConfigured
	}

	var r tally.CachedStatsReporter
	if len(reporters) == 1 {
		r = reporters[0]
	} else {
		r = multi.NewMultiCachedReporter(reporters...)
	}

	scope, closer := mc.NewRootScopeReporter(r)
	return scope, closer, nil
}
1173990
func NewCacheKey(dgst digest.Digest, output Index) *CacheKey {
	return &CacheKey{
		ID:     rootKey(dgst, output).String(),
		digest: dgst,
		output: output,
		ids:    map[*cacheManager]string{},
	}
}
378697
func NewUnregisterArgs(scopeURL string) *UnregisterArgs {
	args := new(UnregisterArgs)
	args.ScopeURL = scopeURL
	return args
}
1264638
func NewMockCoreStrategy(ctrl *gomock.Controller) *MockCoreStrategy {
	mock := &MockCoreStrategy{ctrl: ctrl}
	mock.recorder = &MockCoreStrategyMockRecorder{mock}
	return mock
}
853229
func (e *RuntimeStatsColl) GetRootStats(planID string) *RuntimeStats {
	e.mu.Lock()
	defer e.mu.Unlock()
	runtimeStats, exists := e.rootStats[planID]
	if !exists {
		runtimeStats = &RuntimeStats{}
		e.rootStats[planID] = runtimeStats
	}
	return runtimeStats
}
207418
func NewHistoCounter(sink *Counter) *HistoCounter {
	return &HistoCounter{
		sink:            sink,
		DatapointBucket: sfxclient.NewRollingBucket("datapoint_batch_size", map[string]string{}),
		EventBucket:     sfxclient.NewRollingBucket("event_batch_size", map[string]string{}),
		SpanBucket:      sfxclient.NewRollingBucket("span_batch_size", map[string]string{}),
	}
}
381598
func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, error) {
	errors := make([]error, 0)
	x := &Oauth2Scopes{}
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		// repeated NamedString additional_properties = 1;
		// MAP: string
		x.AdditionalProperties = make([]*NamedString, 0)
		for _, item := range m {
			k, ok := compiler.StringValue(item.Key)
			if ok {
				v := item.Value
				pair := &NamedString{}
				pair.Name = k
				pair.Value = v.(string)
				x.AdditionalProperties = append(x.AdditionalProperties, pair)
			}
		}
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
423859
func AddSystemdScope(systemdRunPath, mountName, command string, args []string) (string, []string) {
	descriptionArg := fmt.Sprintf("--description=Kubernetes transient mount for %s", mountName)
	systemdRunArgs := []string{descriptionArg, "--scope", "--", command}
	return systemdRunPath, append(systemdRunArgs, args...)
}
638312
func newAdminRoot(h *apiHandler, adminAPIs map[int]interface{}) *adminRoot {
	r := &adminRoot{
		apiHandler: h,
		adminAPIs:  adminAPIs,
	}
	return r
}
284659
func (ctx *Context) PopScope() {
	l := len(ctx.scopes)
	if l == 0 {
		panic("no scopes")
	}

	ctx.scopes = ctx.scopes[:l-1]
}
1043266
func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error) {

	if cached && scope != LocalScope {
		return nil, fmt.Errorf("caching supported only for scope %s", LocalScope)
	}
	sequential := false
	if scope == LocalScope {
		sequential = true
	}

	if config == nil {
		config = &store.Config{}
	}

	var addrs []string

	if kv == string(store.BOLTDB) {
		// Parse file path
		addrs = strings.Split(addr, ",")
	} else {
		// Parse URI
		parts := strings.SplitN(addr, "/", 2)
		addrs = strings.Split(parts[0], ",")

		// Add the custom prefix to the root chain
		if len(parts) == 2 {
			rootChain = append([]string{parts[1]}, defaultRootChain...)
		}
	}

	store, err := libkv.NewStore(store.Backend(kv), addrs, config)
	if err != nil {
		return nil, err
	}

	ds := &datastore{scope: scope, store: store, active: true, watchCh: make(chan struct{}), sequential: sequential}
	if cached {
		ds.cache = newCache(ds)
	}

	return ds, nil
}
514505
func DefaultScopes(dataDir string) map[string]*ScopeCfg {
	if dataDir != "" {
		defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db"
		return defaultScopes
	}

	defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db"
	return defaultScopes
}
1020658
func newOauth2oauth_2_0Middleware(scopes []string) *Oauth2oauth_2_0Middleware {
	om := Oauth2oauth_2_0Middleware{}
	om.Scopes = scopes

	return &om
}
764954
func (m *Manager) ScopesForInternalAddrTypes(addrType AddressType) []KeyScope {
	m.mtx.RLock()
	defer m.mtx.RUnlock()

	scopes, _ := m.internalAddrSchemas[addrType]
	return scopes
}
672711
func NewDefaultStochOscWithSrcLen(sourceLength uint) (indicator *StochOsc, err error) {
	ind, err := NewDefaultStochOsc()

	// only initialise the storage if there is enough source data to require it
	if sourceLength-uint(ind.GetLookbackPeriod()) > 1 {
		ind.SlowK = make([]float64, 0, sourceLength-uint(ind.GetLookbackPeriod()))
		ind.SlowD = make([]float64, 0, sourceLength-uint(ind.GetLookbackPeriod()))
	}

	return ind, err
}
1028191
func Scope(xs XStater, scope string, scopes ...string) XStater {
	if c, ok := xs.(Scoper); ok {
		return c.Scope(scope, scopes...)
	}
	return nop
}
307137
func newLogScope(chain chainhash.Hash, op wire.OutPoint) (*logScope, error) {
	var l logScope
	b := bytes.NewBuffer(l[0:0])

	if _, err := b.Write(chain[:]); err != nil {
		return nil, err
	}
	if _, err := b.Write(op.Hash[:]); err != nil {
		return nil, err
	}

	if err := binary.Write(b, endian, op.Index); err != nil {
		return nil, err
	}

	return &l, nil
}