// Backends retrieves the backend(s) with the given type from the account manager.
496037
func (am *Manager) Backends(kind reflect.Type) []Backend {
	return am.backends[kind]
}
273925
func NewBackend(path string) *Backend {
	name := filepath.Ext(path)
	if name != "" {
		name = name[1:]
	}

	return &Backend{
		path: path,
		name: name,
	}
}
199104
func (g *Cloud) ListGlobalBackendServices() ([]*compute.BackendService, error) {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newBackendServiceMetricContext("list", "")
	v, err := g.c.BackendServices().List(ctx, filter.None)
	return v, mc.Observe(err)
}
455650
func BackendFactory(cnf *config.Config) (backendiface.Backend, error) {
	if strings.HasPrefix(cnf.ResultBackend, "amqp://") {
		return amqpbackend.New(cnf), nil
	}

	if strings.HasPrefix(cnf.ResultBackend, "amqps://") {
		return amqpbackend.New(cnf), nil
	}

	if strings.HasPrefix(cnf.ResultBackend, "memcache://") {
		parts := strings.Split(cnf.ResultBackend, "memcache://")
		if len(parts) != 2 {
			return nil, fmt.Errorf(
				"Memcache result backend connection string should be in format memcache://server1:port,server2:port, instead got %s",
				cnf.ResultBackend,
			)
		}
		servers := strings.Split(parts[1], ",")
		return memcachebackend.New(cnf, servers), nil
	}

	if strings.HasPrefix(cnf.ResultBackend, "redis://") {
		redisHost, redisPassword, redisDB, err := ParseRedisURL(cnf.ResultBackend)
		if err != nil {
			return nil, err
		}

		return redisbackend.New(cnf, redisHost, redisPassword, "", redisDB), nil
	}

	if strings.HasPrefix(cnf.ResultBackend, "redis+socket://") {
		redisSocket, redisPassword, redisDB, err := ParseRedisSocketURL(cnf.ResultBackend)
		if err != nil {
			return nil, err
		}

		return redisbackend.New(cnf, "", redisPassword, redisSocket, redisDB), nil
	}

	if strings.HasPrefix(cnf.ResultBackend, "mongodb://") ||
		strings.HasPrefix(cnf.ResultBackend, "mongodb+srv://") {
		return mongobackend.New(cnf)
	}

	if strings.HasPrefix(cnf.ResultBackend, "eager") {
		return eagerbackend.New(), nil
	}

	if strings.HasPrefix(cnf.ResultBackend, "https://dynamodb") {
		return dynamobackend.New(cnf), nil
	}

	return nil, fmt.Errorf("Factory failed with result backend: %v", cnf.ResultBackend)
}
378341
func (c *Client) GetDirectorBackend(i *GetDirectorBackendInput) (*DirectorBackend, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	if i.Director == "" {
		return nil, ErrMissingDirector
	}

	if i.Backend == "" {
		return nil, ErrMissingBackend
	}

	path := fmt.Sprintf("/service/%s/version/%d/director/%s/backend/%s",
		i.Service, i.Version, i.Director, i.Backend)
	resp, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

	var b *DirectorBackend
	if err := decodeJSON(&b, resp.Body); err != nil {
		return nil, err
	}
	return b, nil
}
1182370
func GetBackend(st *state.State) stateShim {
	model, err := st.Model()
	if err != nil {
		logger.Errorf("called GetBackend on a State with no Model.")
		return stateShim{}
	}
	return stateShim{State: st, Model: model}
}
250371
func NewBackend(components ImageComponent, builder Builder, fsCache *fscache.FSCache, buildkit *buildkit.Builder) (*Backend, error) {
	return &Backend{imageComponent: components, builder: builder, fsCache: fsCache, buildkit: buildkit}, nil
}
291289
func New(paths ...string) *Backend {
	backend := &Backend{}

	var files []string
	for _, p := range paths {
		if file, err := os.Open(p); err == nil {
			defer file.Close()
			if fileInfo, err := file.Stat(); err == nil {
				if fileInfo.IsDir() {
					yamlFiles, _ := filepath.Glob(filepath.Join(p, "*.yaml"))
					files = append(files, yamlFiles...)

					ymlFiles, _ := filepath.Glob(filepath.Join(p, "*.yml"))
					files = append(files, ymlFiles...)
				} else if fileInfo.Mode().IsRegular() {
					files = append(files, p)
				}
			}
		}
	}
	for _, file := range files {
		if content, err := ioutil.ReadFile(file); err == nil {
			backend.contents = append(backend.contents, content)
		}
	}
	return backend
}
448349
func NewUserBackend(b *APIBackend) *UserBackend {
	return &UserBackend{
		Logger:                  b.Logger.With(zap.String("handler", "user")),
		UserService:             b.UserService,
		UserOperationLogService: b.UserOperationLogService,
		PasswordsService:        b.PasswordsService,
	}
}
459929
func (b *Backend) GetAll(c context.Context, t backend.GetAllTarget, path string, p backend.Params) (
	[]*config.Config, error) {

	items, err := b.B.GetAll(c, t, path, p)
	if err != nil {
		return nil, err
	}

	if !p.FormatSpec.Unformatted() {
		formatter, err := getFormatter(p.FormatSpec.Formatter)
		if err != nil {
			return nil, errors.Annotate(err, "failed to get formatter for %q, data %q",
				p.FormatSpec.Formatter, p.FormatSpec.Data).Err()
		}

		lme := errors.NewLazyMultiError(len(items))
		for i, item := range items {
			if err := b.formatItem(item, formatter, p.FormatSpec); err != nil {
				lme.Assign(i, err)
			}
		}

		if err := lme.Get(); err != nil {
			return nil, errors.Annotate(err, "failed to format items to %q, data %q",
				p.FormatSpec.Formatter, p.FormatSpec.Data).Err()
		}
	}
	return items, nil
}
501829
func BackendError(b ServiceBackend, zone string, rcode int, state request.Request, err error, opt Options) (int, error) {
	m := new(dns.Msg)
	m.SetRcode(state.Req, rcode)
	m.Authoritative, m.RecursionAvailable, m.Compress = true, true, true
	m.Ns, _ = SOA(b, zone, state, opt)

	state.SizeAndDo(m)
	state.W.WriteMsg(m)
	// Return success as the rcode to signal we have written to the client.
	return dns.RcodeSuccess, err
}
522032
func (b *Backends) Names() []string {
	var names []string
	for _, backend := range b.Backends {
		names = append(names, backend.Name)
	}
	return names
}
439269
func (c *Client) Datastores(ctx context.Context) ([]*mo.Datastore, error) {
	_, datacenter, err := c.finder(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}
	folders, err := datacenter.Folders(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}

	es, err := c.lister(folders.DatastoreFolder.Reference()).List(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var datastores []*mo.Datastore
	for _, e := range es {
		switch o := e.Object.(type) {
		case mo.Datastore:
			datastores = append(datastores, &o)
		}
	}
	return datastores, nil
}
417584
func (o *CacheOptions) WrapBackend(c context.Context, base backend.B) context.Context {
	return backend.WithFactory(c, func(c context.Context) backend.B {
		// Start with our base Backend.
		be := base

		// If our datastore cache is available, fetch settings to see if it's
		// enabled.
		if o.DatastoreCacheAvailable {
			switch s, err := gaeconfig.FetchCachedSettings(c); err {
			case nil:
				// Successfully fetched settings, is our datastore cache enabled?
				switch s.DatastoreCacheMode {
				case gaeconfig.DSCacheEnabled:
					// Datastore cache is enabled, do we have an expiration configured?
					exp := time.Duration(s.CacheExpirationSec) * time.Second
					if exp > 0 {
						// The cache enabled enable. Install it into our backend.
						locker := &dsCacheLocker{}
						dsCfg := datastore.Config{
							RefreshInterval: exp,
							LockerFunc:      func(context.Context) datastorecache.Locker { return locker },
						}
						be = dsCfg.Backend(be)
					}
				}

			default:
				log.WithError(err).Warningf(c, "Failed to fetch datastore cache settings.")
			}
		}

		// Add a proccache-based config cache.
		if o.CacheExpiration > 0 {
			be = caching.LRUBackend(be, messageCache.LRU(c), o.CacheExpiration)
		}

		return be
	})
}
837469
func NewBackendConfig(options Options, backendName string) *BackendConfig {
	return &BackendConfig{
		Options: options,
		name:    backendName,
	}
}
707576
func backendPrintf(format string, args ...interface{}) {
	mux.Lock()
	defer mux.Unlock()
	printerBackend.Printf(format, args...)
}
454217
func ParallelBackends(nBackends uint) ClientParam {
	return func(cl *Client) error {
		if cl.backendParams == nil {
			return ErrClientNotNetworked
		}
		cl.nBackends = nBackends
		return nil
	}
}