// NewBaseService creates a new BaseService.
547060
func NewBaseService(logger log.Logger, name string, impl Service) *BaseService {
	if logger == nil {
		logger = log.NewNopLogger()
	}

	return &BaseService{
		Logger: logger,
		name:   name,
		quit:   make(chan struct{}),
		impl:   impl,
	}
}
747402
func NewNonceService(scope metrics.Scope) (*NonceService, error) {
	scope = scope.NewScope("NonceService")
	key := make([]byte, 16)
	if _, err := rand.Read(key); err != nil {
		return nil, err
	}

	c, err := aes.NewCipher(key)
	if err != nil {
		panic("Failure in NewCipher: " + err.Error())
	}
	gcm, err := cipher.NewGCM(c)
	if err != nil {
		panic("Failure in NewGCM: " + err.Error())
	}

	return &NonceService{
		earliest: 0,
		latest:   0,
		used:     make(map[int64]bool, MaxUsed),
		usedHeap: &int64Heap{},
		gcm:      gcm,
		maxUsed:  MaxUsed,
		stats:    scope,
	}, nil
}
1315776
func NewKeybaseServiceMeasured(delegate KeybaseService, r metrics.Registry) KeybaseServiceMeasured {
	resolveTimer := metrics.GetOrRegisterTimer("KeybaseService.Resolve", r)
	identifyTimer := metrics.GetOrRegisterTimer("KeybaseService.Identify", r)
	normalizeSocialAssertionTimer := metrics.GetOrRegisterTimer("KeybaseService.NormalizeSocialAssertion", r)
	resolveIdentifyImplicitTeamTimer := metrics.GetOrRegisterTimer(
		"KeybaseService.ResolveIdentifyImplicitTeam", r)
	resolveImplicitTeamByIDTimer := metrics.GetOrRegisterTimer(
		"KeybaseService.ResolveImplicitTeamByID", r)
	loadUserPlusKeysTimer := metrics.GetOrRegisterTimer("KeybaseService.LoadUserPlusKeys", r)
	loadTeamPlusKeysTimer := metrics.GetOrRegisterTimer("KeybaseService.LoadTeamPlusKeys", r)
	createTeamTLFTimer := metrics.GetOrRegisterTimer("KeybaseService.CreateTeamTLF", r)
	getTeamSettingsTimer := metrics.GetOrRegisterTimer("KeybaseService.GetTeamSettings", r)
	getCurrentMerkleRootTimer := metrics.GetOrRegisterTimer("KeybaseService.GetCurrentMerkleRoot", r)
	verifyMerkleRootTimer := metrics.GetOrRegisterTimer("KeybaseService.VerifyMerkleRoot", r)
	currentSessionTimer := metrics.GetOrRegisterTimer("KeybaseService.CurrentSession", r)
	favoriteAddTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteAdd", r)
	favoriteDeleteTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteDelete", r)
	favoriteListTimer := metrics.GetOrRegisterTimer("KeybaseService.FavoriteList", r)
	encryptFavoritesTimer := metrics.GetOrRegisterTimer("KeybaseService."+
		"EncryptFavorites", r)
	decryptFavoritesTimer := metrics.GetOrRegisterTimer("KeybaseService."+
		"DecryptFavorites", r)
	notifyTimer := metrics.GetOrRegisterTimer("KeybaseService.Notify", r)
	notifyPathUpdatedTimer := metrics.GetOrRegisterTimer("KeybaseService.NotifyPathUpdated", r)
	putGitMetadataTimer := metrics.GetOrRegisterTimer(
		"KeybaseService.PutGitMetadata", r)
	return KeybaseServiceMeasured{
		delegate:                         delegate,
		resolveTimer:                     resolveTimer,
		identifyTimer:                    identifyTimer,
		normalizeSocialAssertionTimer:    normalizeSocialAssertionTimer,
		resolveIdentifyImplicitTeamTimer: resolveIdentifyImplicitTeamTimer,
		resolveImplicitTeamByIDTimer:     resolveImplicitTeamByIDTimer,
		loadUserPlusKeysTimer:            loadUserPlusKeysTimer,
		loadTeamPlusKeysTimer:            loadTeamPlusKeysTimer,
		createTeamTLFTimer:               createTeamTLFTimer,
		getTeamSettingsTimer:             getTeamSettingsTimer,
		getCurrentMerkleRootTimer:        getCurrentMerkleRootTimer,
		verifyMerkleRootTimer:            verifyMerkleRootTimer,
		currentSessionTimer:              currentSessionTimer,
		favoriteAddTimer:                 favoriteAddTimer,
		favoriteDeleteTimer:              favoriteDeleteTimer,
		favoriteListTimer:                favoriteListTimer,
		encryptFavoritesTimer:            encryptFavoritesTimer,
		decryptFavoritesTimer:            decryptFavoritesTimer,
		notifyTimer:                      notifyTimer,
		notifyPathUpdatedTimer:           notifyPathUpdatedTimer,
		putGitMetadataTimer:              putGitMetadataTimer,
	}
}
912932
func NewBaseDfbReport(StartDate string) *BaseDfbReport {
	s := new(BaseDfbReport)
	s.StartDate = StartDate
	return s
}
1183192
func newBaseQuery() baseQuery {
	return baseQuery{
		storeLimit:    DefaultMaxResultsPerColumnFamily,
		fromTimestamp: MinTimestamp,
		toTimestamp:   MaxTimestamp,
		maxVersions:   DefaultMaxVersions,
	}
}
687263
func NewBaseInput(outpoint *wire.OutPoint, witnessType WitnessType,
	signDescriptor *SignDescriptor, heightHint uint32) *BaseInput {

	input := MakeBaseInput(
		outpoint, witnessType, signDescriptor, heightHint,
	)

	return &input
}
292112
func (h *Service) NewDatabase(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	srcID, err := paramID("id", r)
	if err != nil {
		Error(w, http.StatusUnprocessableEntity, err.Error(), h.Logger)
		return
	}

	src, err := h.Store.Sources(ctx).Get(ctx, srcID)
	if err != nil {
		notFound(w, srcID, h.Logger)
		return
	}

	dbsvc := h.Databases

	if err = dbsvc.Connect(ctx, &src); err != nil {
		msg := fmt.Sprintf("unable to connect to source %d: %v", srcID, err)
		Error(w, http.StatusBadRequest, msg, h.Logger)
		return
	}

	postedDB := &chronograf.Database{}
	if err := json.NewDecoder(r.Body).Decode(postedDB); err != nil {
		invalidJSON(w, h.Logger)
		return
	}

	if err := ValidDatabaseRequest(postedDB); err != nil {
		invalidData(w, err, h.Logger)
		return
	}

	database, err := dbsvc.CreateDB(ctx, postedDB)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), h.Logger)
		return
	}

	rps, err := h.allRPs(ctx, dbsvc, srcID, database.Name)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), h.Logger)
		return
	}
	res := newDBResponse(srcID, database.Name, rps)
	encodeJSON(w, http.StatusCreated, res, h.Logger)
}
706592
func NewTeamService(context servicecontext.ServiceContext) service.TeamService {
	return &teamServiceImpl{base.NewBaseService(context)}
}
368484
func NewWITService(context servicecontext.ServiceContext, config wit.Configuration) service.WITService {
	return &witServiceImpl{base.NewBaseService(context), config, rest.DefaultHttpDoer()}
}
72577
func (c *ConfigLocal) SetKeybaseService(k KeybaseService) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.service = k
}
1118139
func createService(c context.Context, opts auth.Options) (*compute.Service, error) {
	http, err := auth.NewAuthenticator(c, auth.OptionalLogin, opts).Client()
	if err != nil {
		return nil, err
	}
	service, err := compute.New(http)
	if err != nil {
		return nil, err
	}
	return service, nil
}
153290
func newElementBase(ln *line, parent element) elementBase {
	return elementBase{
		ln:     ln,
		parent: parent,
	}
}
1132901
func NewBase(n string) *Base {
	return &Base{
		name:       n,
		reset:      func() {},
		closer:     func() error { return nil },
		errHandler: func(error, message.Composer) {},
	}
}
181988
func (gsvc *GlobalServices) Base(c *router.Context, next router.Handler) {
	services := flexServicesInst{
		GlobalServices: gsvc,
	}

	c.Context = coordinator.WithConfigProvider(c.Context, &services)
	c.Context = WithServices(c.Context, &services)
	next(c)
}
756057
func NewBaseHandler(name string, level LogLevelType) *BaseHandler {
	return &BaseHandler{
		StandardFilterer: NewStandardFilterer(),
		name:             name,
		level:            level,
		formatter:        nil,
	}
}
1162744
func NewNotificationService(context servicecontext.ServiceContext, config notification.Configuration) service.NotificationService {
	return &notificationServiceImpl{
		BaseService: base.NewBaseService(context),
		config:      config,
	}
}
817177
func NewLinkService(context servicecontext.ServiceContext, config LinkServiceConfiguration) service.LinkService {
	return &linkServiceImpl{
		BaseService: base.NewBaseService(context),
		config:      config,
	}
}