// OnBackendMutated should be called when state of the associated backend is
// changed, e.g. when a new backend server is added or something like that.
164960
func (fe *T) OnBackendMutated() {
	fe.mu.Lock()
	fe.ready = false
	fe.mu.Unlock()
}
1279846
func (dc *Config) Backend(base backend.B) backend.B {
	return &caching.Backend{
		B:           base,
		FailOnError: !dc.FailOpen,
		CacheGet:    dc.cacheGet,
	}
}
1094341
func (builder *StoreBucketPropsCommandBuilder) WithBackend(backend string) *StoreBucketPropsCommandBuilder {
	builder.props.Backend = []byte(backend)
	return builder
}
895799
func (hc *HealthCheck) SetBackendsConfiguration(parentCtx context.Context, backends map[string]*BackendConfig) {
	hc.Backends = backends
	if hc.cancel != nil {
		hc.cancel()
	}
	ctx, cancel := context.WithCancel(parentCtx)
	hc.cancel = cancel

	for _, backend := range backends {
		currentBackend := backend
		safe.Go(func() {
			hc.execute(ctx, currentBackend)
		})
	}
}
463930
func (ctx *Context) UpdateBackend(vsID, rsID string, weight int32) (int32, error) {
	ctx.mutex.Lock()
	defer ctx.mutex.Unlock()
	return ctx.updateBackend(vsID, rsID, weight)
}
273925
func NewBackend(path string) *Backend {
	name := filepath.Ext(path)
	if name != "" {
		name = name[1:]
	}

	return &Backend{
		path: path,
		name: name,
	}
}
1174211
func newBackendImplementation(backendType SupportedBackend, config *BackendConfig) Backend {
	var requestMetricsBuffer chan requestMetrics
	enableTelemetry := config.EnableTelemetry || EnableTelemetry

	// only allocate the requestMetrics buffer if client telemetry is enabled.
	if enableTelemetry {
		requestMetricsBuffer = make(chan requestMetrics, telemetryBufferSize)
	}

	return &BackendImplementation{
		HTTPClient:           config.HTTPClient,
		LeveledLogger:        config.LeveledLogger,
		MaxNetworkRetries:    config.MaxNetworkRetries,
		Type:                 backendType,
		URL:                  config.URL,
		enableTelemetry:      enableTelemetry,
		networkRetriesSleep:  true,
		requestMetricsBuffer: requestMetricsBuffer,
	}
}
979739
func New(cnf *config.Config, servers []string) iface.Backend {
	return &Backend{
		Backend: common.NewBackend(cnf),
		servers: servers,
	}
}
354577
func ConfigFromBackend(coreBackend ...core.ConfigBackend) (fab.EndpointConfig, error) {

	config := &EndpointConfig{
		backend: lookup.New(coreBackend...),
	}

	if err := config.loadEndpointConfiguration(); err != nil {
		return nil, errors.WithMessage(err, "network configuration load failed")
	}

	//print deprecated warning
	detectDeprecatedNetworkConfig(config)

	return config, nil
}
1315065
func NewBackend(delegate audit.Backend, p policy.Checker) audit.Backend {
	return &Backend{
		policyChecker:   p,
		delegateBackend: delegate,
	}
}
1258490
func (l *lbmapCache) addBackendV2Locked(addrID BackendAddrID) bool {
	l.backendRefCount[addrID]++
	return l.backendRefCount[addrID] == 1
}
769165
func (gce *Cloud) UpdateBackendService(bg *compute.BackendService) error {
	op, err := gce.service.BackendServices.Update(gce.projectID, bg.Name, bg).Do()
	if err != nil {
		return err
	}
	return gce.waitForGlobalOp(op)
}
1195372
func (stack *middlewareStack) OnBeforeNotify(middleware beforeFunc) {
	stack.before = append(stack.before, middleware)
}
960882
func NewLBBackEnd(id BackendID, protocol L4Type, ip net.IP, portNumber uint16, weight uint16) *LBBackEnd {
	lbport := NewL4Addr(protocol, portNumber)
	lbbe := LBBackEnd{
		ID:       BackendID(id),
		L3n4Addr: L3n4Addr{IP: ip, L4Addr: *lbport},
		Weight:   weight,
	}
	log.WithField("backend", lbbe).Debug("created new LBBackend")

	return &lbbe
}
575607
func (o *AuditWebhookOptions) newUntruncatedBackend() (audit.Backend, error) {
	groupVersion, _ := schema.ParseGroupVersion(o.GroupVersionString)
	webhook, err := pluginwebhook.NewBackend(o.ConfigFile, groupVersion, o.InitialBackoff)
	if err != nil {
		return nil, fmt.Errorf("initializing audit webhook: %v", err)
	}
	webhook = o.BatchOptions.wrapBackend(webhook)
	return webhook, nil
}
540832
func Backend(b backend.B, exp time.Duration) backend.B {
	return &caching.Backend{
		B: b,
		CacheGet: func(c context.Context, key caching.Key, l caching.Loader) (*caching.Value, error) {
			if key.Authority != backend.AsService {
				return l(c, key, nil)
			}

			// Is the item already cached?
			k := memcacheKey(&key)
			mci, err := mc.GetKey(c, k)
			switch err {
			case nil:
				// Value was cached, successfully retrieved.
				v, err := caching.DecodeValue(mci.Value())
				if err != nil {
					return nil, errors.Annotate(err, "failed to decode cache value from %q", k).Err()
				}
				return v, nil

			case mc.ErrCacheMiss:
				// Value was not cached. Load from Loader and cache.
				v, err := l(c, key, nil)
				if err != nil {
					return nil, err
				}

				// Attempt to cache the value. If this fails, we'll log a warning and
				// move on.
				err = func() error {
					d, err := v.Encode()
					if err != nil {
						return errors.Annotate(err, "failed to encode value").Err()
					}

					if len(d) > maxMemCacheSize {
						return errors.Reason("entry exceeds memcache size (%d > %d)", len(d), maxMemCacheSize).Err()
					}

					item := mc.NewItem(c, k).SetValue(d).SetExpiration(exp)
					if err := mc.Set(c, item); err != nil {
						return errors.Annotate(err, "").Err()
					}
					return nil
				}()
				if err != nil {
					log.Fields{
						log.ErrorKey: err,
						"key":        k,
					}.Warningf(c, "Failed to cache config.")
				}

				// Return the loaded value.
				return v, nil

			default:
				// Unknown memcache error.
				log.Fields{
					log.ErrorKey: err,
					"key":        k,
				}.Warningf(c, "Failed to decode memcached config.")
				return l(c, key, nil)
			}
		},
	}
}
574498
func NewBackend() backend.Backend {
	return backend.Func("env", func(ctx context.Context, key string) ([]byte, error) {
		val, ok := os.LookupEnv(key)
		if ok {
			return []byte(val), nil
		}

		key = strings.Replace(strings.ToUpper(key), "-", "_", -1)

		val, ok = os.LookupEnv(key)
		if ok {
			return []byte(val), nil
		}

		return nil, backend.ErrNotFound
	})
}