// SetBackend sets the backend used in the binding.
548614
func SetBackend(backend SupportedBackend, b Backend) {
	switch backend {
	case APIBackend:
		backends.API = b
	case UploadsBackend:
		backends.Uploads = b
	}
}
875883
func Backend() *backend {
	var b backend
	b.Backend = &framework.Backend{
		Help: "",
		Paths: framework.PathAppend(
			errorPaths(&b),
			kvPaths(&b),
			[]*framework.Path{
				pathInternal(&b),
				pathSpecial(&b),
				pathRaw(&b),
			},
		),
		PathsSpecial: &logical.Paths{
			Unauthenticated: []string{
				"special",
			},
		},
		Secrets:     []*framework.Secret{},
		Invalidate:  b.invalidate,
		BackendType: logical.TypeLogical,
	}
	b.internal = "bar"
	return &b
}
996519
func (s *SpheroDriver) SetBackLED(level uint8) {
	s.packetChannel <- s.craftPacket([]uint8{level}, 0x02, 0x21)
}
932141
func NewSetupBackend(b *APIBackend) *SetupBackend {
	return &SetupBackend{
		Logger:            b.Logger.With(zap.String("handler", "setup")),
		OnboardingService: b.OnboardingService,
	}
}
797034
func NewBackend(c config.Config) (gateway.Gateway, error) {
	var err error
	var ok bool

	conf := c.NetworkServer.Gateway.Backend.AzureIoTHub

	b := Backend{
		uplinkFrameChan:   make(chan gw.UplinkFrame),
		gatewayStatsChan:  make(chan gw.GatewayStats),
		downlinkTxAckChan: make(chan gw.DownlinkTXAck),
		gatewayMarshaler:  make(map[lorawan.EUI64]marshaler.Type),

		ctx: context.Background(),
	}

	b.ctx, b.cancel = context.WithCancel(b.ctx)

	connProperties, err := parseConnectionString(conf.EventsConnectionString)
	if err != nil {
		return nil, errors.Wrap(err, "parse connection-string error")
	}

	b.queueName, ok = connProperties["EntityPath"]
	if !ok {
		return nil, errors.New("connection-string does not contain 'EntityPath', please use the queue connection-string")
	}

	log.Info("gateway/azure_iot_hub: setting up service-bus namespace")
	b.ns, err = servicebus.NewNamespace(
		servicebus.NamespaceWithConnectionString(conf.EventsConnectionString),
	)
	if err != nil {
		return nil, errors.Wrap(err, "new namespace error")
	}

	b.queue, err = b.ns.NewQueue(b.queueName)
	if err != nil {
		return nil, errors.Wrap(err, "new queue client error")
	}

	b.iotClient, err = iotservice.New(
		iotservice.WithConnectionString(conf.CommandsConnectionString),
	)
	if err != nil {
		return nil, errors.Wrap(err, "new iotservice client error")
	}

	go func() {
		log.WithField("queue", b.queueName).Info("gateway/azure_iot_hub: starting queue consumer")
		for {
			if b.closed {
				break
			}

			if err := b.queue.Receive(b.ctx, servicebus.HandlerFunc(b.eventHandler)); err != nil {
				log.WithError(err).Error("gateway/azure_iot_hub: receive from queue error")
				time.Sleep(time.Second * 2)
			}

		}
	}()

	return &b, nil
}
143720
func (s *UpdateStackInput) SetFeedbackURL(v string) *UpdateStackInput {
	s.FeedbackURL = &v
	return s
}
469066
func (s *BackupDetails) SetBackupType(v string) *BackupDetails {
	s.BackupType = &v
	return s
}
642080
func (m *monitoring) backend() Backend {
	if m.b == nil {
		m.b = NewStandardBackend()
	}
	return m.b
}
960749
func (a *SetFileInputFilesArgs) SetBackendNodeID(backendNodeID BackendNodeID) *SetFileInputFilesArgs {
	a.BackendNodeID = &backendNodeID
	return a
}
439288
func getBackend(name string) backendModule {
	if backend, ok := registeredBackends[name]; ok {
		return backend.createInstance()
	}

	return nil
}
448557
func devServerBackend() backend.B {
	pwd := os.Getenv("PWD") // os.Getwd works funny with symlinks, use PWD
	candidates := []string{
		filepath.Join(pwd, devCfgDir),
		filepath.Join(filepath.Dir(pwd), devCfgDir),
	}
	for _, dir := range candidates {
		if _, err := os.Stat(dir); err == nil {
			fs, err := filesystem.New(dir)
			if err != nil {
				return erroring.New(err)
			}
			return &client.Backend{&testconfig.Provider{
				Base: fs,
			}}
		}
	}
	return erroring.New(fmt.Errorf("luci-config: could not find local configs in any of %s", candidates))
}
588796
func (s *CreateStackInput) SetFeedbackURL(v string) *CreateStackInput {
	s.FeedbackURL = &v
	return s
}
186137
func NewHTTPBackend(id string, s HTTPBackendSettings) (*Backend, error) {
	if _, err := s.TransportSettings(); err != nil {
		return nil, err
	}
	return &Backend{
		Id:       id,
		Type:     HTTP,
		Settings: s,
	}, 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)
			}
		},
	}
}
267008
func (s *ViewBillingInput) SetEnd(v time.Time) *ViewBillingInput {
	s.End = &v
	return s
}
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)
		})
	}
}
742329
func (c *Client) CreateBackend(i *CreateBackendInput) (*Backend, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

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

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

	var b *Backend
	if err := decodeJSON(&b, resp.Body); err != nil {
		return nil, err
	}
	return b, nil
}