// NewService creates an instance of a Service.
761
func NewService() *Service {
	s := &Service{
		TokenGenerator: rand.NewTokenGenerator(64),
		IDGenerator:    snowflake.NewIDGenerator(),
		time:           time.Now,
	}
	s.initializeSources(context.TODO())
	return s
}
208689
func (ccr *ccResolverWrapper) NewServiceConfig(sc string) {
	if ccr.isDone() {
		return
	}
	grpclog.Infof("ccResolverWrapper: got new service config: %v", sc)
	if channelz.IsOn() {
		ccr.addChannelzTraceEvent(resolver.State{Addresses: ccr.curState.Addresses, ServiceConfig: sc})
	}
	ccr.curState.ServiceConfig = sc
	ccr.cc.updateResolverState(ccr.curState)
}
980559
func NewSearchService(client *Client) *SearchService {
	builder := &SearchService{
		client:       client,
		searchSource: NewSearchSource(),
	}
	return builder
}
736521
func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
	scopesOption := option.WithScopes(
		"https://www.googleapis.com/auth/userinfo.email",
	)
	// NOTE: prepend, so we don't override user-specified scopes.
	opts = append([]option.ClientOption{scopesOption}, opts...)
	client, endpoint, err := htransport.NewClient(ctx, opts...)
	if err != nil {
		return nil, err
	}
	s, err := New(client)
	if err != nil {
		return nil, err
	}
	if endpoint != "" {
		s.BasePath = endpoint
	}
	return s, nil
}
913002
func NewService(ip net.IP, headless bool, labels map[string]string, selector map[string]string) *Service {
	return &Service{
		FrontendIP: ip,
		IsHeadless: headless,
		Ports:      map[loadbalancer.FEPortName]*loadbalancer.FEPort{},
		Labels:     labels,
		Selector:   selector,
	}
}
560833
func NewService(options ServiceOptions) (*DefaultService, error) {
	config, err := newServiceConfig(options)

	return &DefaultService{config: config}, err
}
672851
func NewService(config Config, sup Support) *service {
	s := &service{
		auth: newAuthCache(sup, authCacheConfig{
			enabled:             config.AuthCacheEnabled,
			maxCacheSize:        config.AuthCacheMaxSize,
			purgeRetentionRatio: config.AuthCachePurgeRetentionRatio,
		}),
		Support: sup,
	}
	s.channelDispatchers = map[discovery.QueryType]dispatcher{
		discovery.ConfigQueryType:         s.configQuery,
		discovery.ChaincodeQueryType:      s.chaincodeQuery,
		discovery.PeerMembershipQueryType: s.channelMembershipResponse,
	}
	s.localDispatchers = map[discovery.QueryType]dispatcher{
		discovery.LocalMembershipQueryType: s.localMembershipResponse,
	}
	logger.Info("Created with config", config)
	return s
}
448192
func NewSessionService() *SessionService {
	return &SessionService{
		FindSessionFn:   func(context.Context, string) (*platform.Session, error) { return nil, fmt.Errorf("mock session") },
		CreateSessionFn: func(context.Context, string) (*platform.Session, error) { return nil, fmt.Errorf("mock session") },
		ExpireSessionFn: func(context.Context, string) error { return fmt.Errorf("mock session") },
		RenewSessionFn: func(ctx context.Context, session *platform.Session, expiredAt time.Time) error {
			return fmt.Errorf("mock session")
		},
	}
}
255263
func (i *Handle) NewService(s *Service) error {
	return i.doCmd(s, nil, ipvsCmdNewService)
}
311275
func NewSecretService() (*SecretService, error) {
	conn, err := dbus.SessionBus()
	if err != nil {
		return nil, err
	}

	return &SecretService{
		conn,
		conn.Object(serviceName, servicePath),
	}, nil
}
431224
func NewServiceLabel(s string) (ServiceLabel, error) {
	switch s {
	case string(AppServiceLabel):
		return AppServiceLabel, nil
	case string(BrewServiceLabel):
		return BrewServiceLabel, nil
	case string(AppKBFSLabel):
		return AppKBFSLabel, nil
	case string(BrewKBFSLabel):
		return BrewKBFSLabel, nil
	case string(AppUpdaterLabel):
		return AppUpdaterLabel, nil
	}
	return UnknownLabel, fmt.Errorf("Unknown service label: %s", s)
}
680513
func NewService(addr, token string) *Service {
	return &Service{
		Addr:  addr,
		Token: token,
		AuthorizationService: &AuthorizationService{
			Addr:  addr,
			Token: token,
		},
		OrganizationService: &OrganizationService{
			Addr:  addr,
			Token: token,
		},
		UserService: &UserService{
			Addr:  addr,
			Token: token,
		},
		BucketService: &BucketService{
			Addr:  addr,
			Token: token,
		},
		QueryService: &QueryService{
			Addr:  addr,
			Token: token,
		},
		DashboardService: &DashboardService{
			Addr:  addr,
			Token: token,
		},
		MacroService: &MacroService{
			Addr:  addr,
			Token: token,
		},
	}
}
1212921
func NewServiceFactory(producer servicecontext.ServiceContextProducer, config *configuration.ConfigurationData, options ...Option) *ServiceFactory {
	f := &ServiceFactory{contextProducer: producer, config: config}
	// default function to return an instance of WIT Service
	f.witServiceFunc = func() service.WITService {
		return witservice.NewWITService(f.getContext(), f.config)
	}
	// default function to return an instance of Tenant Service
	f.tenantServiceFunc = func() service.TenantService {
		return userservice.NewTenantService(f.config)
	}
	// default function to return an instance of Notification Service
	f.notificationServiceFunc = func() service.NotificationService {
		return notificationservice.NewNotificationService(f.getContext(), f.config)
	}
	// default function to return an instance of Cluster Service
	f.clusterServiceFunc = func() service.ClusterService {
		return clusterservice.NewClusterService(f.getContext(), f.config)
	}
	// default function to return an instance of Auth Service
	f.authProviderServiceFunc = func() service.AuthenticationProviderService {
		return providerservice.NewAuthenticationProviderService(f.getContext(), f.config)
	}
	// default function to return an instance of User Service
	f.userServiceFunc = func() service.UserService {
		return userservice.NewUserService(f.getContext(), f.config)
	}
	log.Info(nil, map[string]interface{}{}, "configuring a new service factory with %d option(s)", len(options))
	// and options
	for _, opt := range options {
		opt(f)
	}
	return f
}
1130584
func NewServiceScheduler(logger log.Logger, state State, planner Planner) Scheduler {
	s := &GenericScheduler{
		logger:  logger.Named("service_sched"),
		state:   state,
		planner: planner,
		batch:   false,
	}
	return s
}
963416
func NewServiceCache() ServiceCache {
	return ServiceCache{
		services:          map[ServiceID]*Service{},
		endpoints:         map[ServiceID]*Endpoints{},
		ingresses:         map[ServiceID]*Service{},
		externalEndpoints: map[ServiceID]externalEndpoints{},
		Events:            make(chan ServiceEvent, 128),
	}
}
169195
func newServiceAccounts(c *Client, ns string) ServiceAccountsInterface {
	return &serviceAccounts{
		client:    c,
		namespace: ns,
	}
}
156786
func NewServiceWithLogger(serviceName string, client *api.Client,
	logger *log.Logger) (*Service, error) {
	s := &Service{
		service:              serviceName,
		client:               client,
		logger:               logger,
		tlsCfg:               newDynamicTLSConfig(defaultTLSConfig(), logger),
		httpResolverFromAddr: ConsulResolverFromAddrFunc(client),
	}

	// Set up root and leaf watches
	p, err := watch.Parse(map[string]interface{}{
		"type": "connect_roots",
	})
	if err != nil {
		return nil, err
	}
	s.rootsWatch = p
	s.rootsWatch.HybridHandler = s.rootsWatchHandler

	p, err = watch.Parse(map[string]interface{}{
		"type":    "connect_leaf",
		"service": s.service,
	})
	if err != nil {
		return nil, err
	}
	s.leafWatch = p
	s.leafWatch.HybridHandler = s.leafWatchHandler

	go s.rootsWatch.RunWithClientAndLogger(client, s.logger)
	go s.leafWatch.RunWithClientAndLogger(client, s.logger)

	return s, nil
}