// KeybaseService implements the Config interface for ConfigLocal.
438807
func (c *ConfigLocal) KeybaseService() KeybaseService {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.service
}
425796
func (c *Subcommand) ConfigService(ctx context.Context, host string) (*config.Service, error) {
	authOpts, err := c.authFlags.Options()
	if err != nil {
		return nil, err
	}
	client, err := auth.NewAuthenticator(ctx, auth.SilentLogin, authOpts).Client()
	if err != nil {
		return nil, err
	}

	svc, err := config.New(client)
	if err != nil {
		return nil, err
	}
	svc.BasePath = fmt.Sprintf("https://%s/_ah/api/config/v1/", host)
	svc.UserAgent = lucicfg.UserAgent
	return svc, nil
}
400508
func (a *api) AddService(config ServiceConfig) (*service.ServiceDetails, error) {
	client, err := a.connectDAO()
	if err != nil {
		return nil, err
	}

	endpoints := make([]servicedefinition.EndpointDefinition, len(*config.LocalPorts)+len(*config.RemotePorts))
	i := 0
	for _, e := range *config.LocalPorts {
		e.Purpose = "local"
		endpoints[i] = e
		i++
	}
	for _, e := range *config.RemotePorts {
		e.Purpose = "remote"
		endpoints[i] = e
		i++
	}

	sd := &servicedefinition.ServiceDefinition{
		Name:      config.Name,
		Command:   config.Command,
		Instances: domain.MinMax{Min: 1, Max: 1, Default: 1},
		ImageID:   config.ImageID,
		Launch:    commons.AUTO,
		Endpoints: endpoints,
	}

	var serviceID string
	if err := client.DeployService(dao.ServiceDeploymentRequest{ParentID: config.ParentServiceID, Service: *sd}, &serviceID); err != nil {
		return nil, err
	}

	return a.GetServiceDetails(serviceID)
}
41671
func NewSharedKeybaseConnection(kbCtx Context, config Config,
	handler rpc.ConnectionHandler) *rpc.Connection {
	transport := &SharedKeybaseTransport{kbCtx: kbCtx}
	constBackoff := backoff.NewConstantBackOff(RPCReconnectInterval)
	opts := rpc.ConnectionOpts{
		WrapErrorFunc:    libkb.WrapError,
		TagsFunc:         libkb.LogTagsFromContext,
		ReconnectBackoff: func() backoff.BackOff { return constBackoff },
	}
	return rpc.NewConnectionWithTransport(
		handler, transport, libkb.ErrorUnwrapper{},
		logger.LogOutputWithDepthAdder{Logger: config.MakeLogger("")}, opts)
}
1321835
func (f *Facade) syncService(ctx datastore.Context, tenantID, serviceID string, setLockOnCreate, setLockOnUpdate bool) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.syncService"))
	svc, err := f.GetService(ctx, serviceID)
	if err != nil {
		glog.Errorf("Could not get service %s to sync: %s", serviceID, err)
		return err
	}
	if err := f.zzk.UpdateService(ctx, tenantID, svc, setLockOnCreate, setLockOnUpdate); err != nil {
		glog.Errorf("Could not sync service %s to the coordinator: %s", serviceID, err)
		return err
	}
	return nil
}
282214
func DeleteService(key ServiceKey) error {
	mutex.Lock()
	defer mutex.Unlock()

	err := deleteServiceLocked(key)
	if err != nil {
		return err
	}

	return nil
}
171887
func (client *Client) CreateServiceKey(serviceInstanceGUID string, keyName string, parameters map[string]interface{}) (ServiceKey, Warnings, error) {
	requestBody := serviceKeyRequestBody{
		ServiceInstanceGUID: serviceInstanceGUID,
		Name:                keyName,
		Parameters:          parameters,
	}

	bodyBytes, err := json.Marshal(requestBody)
	if err != nil {
		return ServiceKey{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostServiceKeyRequest,
		Body:        bytes.NewReader(bodyBytes),
	})
	if err != nil {
		return ServiceKey{}, nil, err
	}

	var serviceKey ServiceKey
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &serviceKey,
	}
	err = client.connection.Make(request, &response)

	return serviceKey, response.Warnings, err
}
994621
func NewKBFSService(kbCtx Context, config kbfsServiceConfig) (
	*KBFSService, error) {
	log := config.MakeLogger("FSS")
	// Check to see if we're receiving a socket from systemd. If not, create
	// one and bind to it.
	listener, err := systemd.GetListenerFromEnvironment()
	if err != nil {
		return nil, err
	}
	if listener != nil {
		log.Debug("Found listener in the environment. Listening on fd 3.")
	} else {
		log.Debug("No listener found in the environment. Binding a new socket.")
		listener, err = kbCtx.BindToKBFSSocket()
		if err != nil {
			return nil, err
		}
	}
	k := &KBFSService{
		config: config,
		log:    log,
		kbCtx:  kbCtx,
	}
	k.Run(listener)
	return k, nil
}
117738
func (k KeybaseServiceMeasured) ClearCaches(ctx context.Context) {
	k.delegate.ClearCaches(ctx)
}
175181
func (ec *ServiceManager) BindService(service RunnableInterface) {
	ec.services = append(ec.services, service)
}
736147
func DNSService(dnsService *dns.Service) Option {
	return func(c *Client) error {
		c.dnsService = dnsService
		return nil
	}
}
1023164
func ServiceStatus(context Context, label ServiceLabel, wait time.Duration, log Log) (*keybase1.ServiceStatus, error) {
	switch label.ComponentName() {
	case ComponentNameService:
		st := KeybaseServiceStatus(context, string(label), wait, log)
		return &st, nil
	case ComponentNameKBFS:
		st := KBFSServiceStatus(context, string(label), wait, log)
		return &st, nil
	case ComponentNameUpdater:
		st := UpdaterServiceStatus(context, string(label))
		return &st, nil
	default:
		return nil, fmt.Errorf("Invalid label: %s", label)
	}
}
411317
func (service *BaseService) AddInvokeHandler(handler ...InvokeHandler) Service {
	service.handlerManager.AddInvokeHandler(handler...)
	return service
}
1151133
func (k Key) BaseNamespace() string {
	n := k.Namespaces()
	return n[len(n)-1]
}
440946
func NewCachedKeyService(baseKeyService signed.CryptoService) signed.CryptoService {
	return &cachedKeyService{
		CryptoService: baseKeyService,
		lock:          &sync.RWMutex{},
		cachedKeys:    make(map[string]*cachedKey),
	}
}
238292
func NewUserService(ctx servicecontext.ServiceContext, config UserServiceConfiguration) service.UserService {
	return &userServiceImpl{
		BaseService: base.NewBaseService(ctx),
		config:      config,
	}
}
756092
func (csp *impl) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error) {
	return nil, nil
}