// newCaller can be used to instantiate configManager,
// however, it is exported as ConfigCaller and avoids
// starting kvdb watches.
// Those not needing kvdb wtches should use this instead of
// config manager.
975863
func newCaller(kv kvdb.Kvdb) (*configManager, error) {
	manager := new(configManager)

	manager.cbCluster = make(map[string]CallbackClusterConfigFunc)
	manager.cbNode = make(map[string]CallbackNodeConfigFunc)

	// kvdb pointer
	manager.kv = kv

	return manager, nil
}
449338
func NewWorker(st *keyupdater.State, agentConfig agent.Config) (worker.Worker, error) {
	machineTag, ok := agentConfig.Tag().(names.MachineTag)
	if !ok {
		return nil, errors.NotValidf("machine tag %v", agentConfig.Tag())
	}
	if os.HostOS() == os.Windows {
		return jworker.NewNoOpWorker(), nil
	}
	w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
		Handler: &keyupdaterWorker{
			st:  st,
			tag: machineTag,
		},
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
1346989
func NewCollector(options ...func(*Collector)) *Collector {
	c := &Collector{}
	c.Init()

	for _, f := range options {
		f(c)
	}

	c.parseSettingsFromEnv()

	return c
}
731143
func NewDialer(upgrader Upgrader, client *http.Client, method string, url *url.URL) httpstream.Dialer {
	return &dialer{
		client:   client,
		upgrader: upgrader,
		method:   method,
		url:      url,
	}
}
92857
func NewHandler(c Config) func(http.Handler) http.Handler {
	if c.Output == nil {
		c.Output = NewOutputChannel(NewConsoleOutput())
	}
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			var l Logger
			if r != nil {
				l = New(c)
				r = r.WithContext(NewContext(r.Context(), l))
			}
			next.ServeHTTP(w, r)
			if l, ok := l.(*logger); ok {
				l.close()
			}
		})
	}
}
483554
func NewStandardEtcdConfigManager(machines []string) (ConfigManager, error) {
	store, err := etcd.New(machines)
	if err != nil {
		return nil, err
	}

	return NewStandardConfigManager(store)
}
828603
func (p *Plugin) NewWatcher(keyPrefix string) keyval.ProtoWatcher {
	return p.protoWrapper.NewWatcher(keyPrefix)
}
816786
func NewWorker(config WorkerConfig) (worker.Worker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	// Don't return from NewWorker until the loop has started and
	// has subscribed to everything.
	started := make(chan struct{})
	w := &wrapper{
		origin:   config.Origin,
		hub:      config.Hub,
		recorder: config.Recorder,
		logger:   config.Logger,
	}
	w.tomb.Go(func() error {
		return w.loop(started)
	})
	select {
	case <-started:
	case <-time.After(10 * time.Second):
		return nil, errors.New("worker failed to start properly")
	}
	return w, nil
}
227901
func NewMockManager(id string, cancel context.CancelFunc) Manager {
	return &mockManager{
		id:     id,
		cancel: cancel,
	}
}
487762
func NewENSRegistryCaller(address common.Address, caller bind.ContractCaller) (*ENSRegistryCaller, error) {
	contract, err := bindENSRegistry(address, caller, nil, nil)
	if err != nil {
		return nil, err
	}
	return &ENSRegistryCaller{contract: contract}, nil
}
455303
func NewHandler(Next httpserver.Handler, config *Config) *Handler {
	return &Handler{
		Config:   config,
		Cache:    NewHTTPCache(config.CacheKeyTemplate),
		URLLocks: NewURLLock(),
		Next:     Next,
	}
}
832725
func (cfgSrcHandler *Handler) DynamicConfigHandler(callback core.DynamicConfigCallback) error {
	if cfgSrcHandler.initSuccess != true {
		return errors.New("config center source initialization failed")
	}

	dynCfgHandler, err := newDynConfigHandlerSource(cfgSrcHandler, callback)
	if err != nil {
		openlogging.GetLogger().Error("failed to initialize dynamic config center Handler:" + err.Error())
		return errors.New("failed to initialize dynamic config center Handler")
	}
	cfgSrcHandler.dynamicConfigHandler = dynCfgHandler

	if cfgSrcHandler.RefreshMode == 0 {
		// Pull All the configuration for the first time.
		cfgSrcHandler.refreshConfigurations("")
		//Start a web socket connection to recieve change events.
		dynCfgHandler.startDynamicConfigHandler()
	}

	return nil
}
1010190
func New(cfg *Config) (*ConnManager, error) {
	if cfg.Dial == nil {
		return nil, ErrDialNil
	}
	// Default to sane values
	if cfg.RetryDuration <= 0 {
		cfg.RetryDuration = defaultRetryDuration
	}
	if cfg.TargetOutbound == 0 {
		cfg.TargetOutbound = defaultTargetOutbound
	}
	cm := ConnManager{
		cfg:      *cfg, // Copy so caller can't mutate
		requests: make(chan interface{}),
		quit:     make(chan struct{}),
	}
	return &cm, nil
}
446767
func NewCallWrapper(ot opentracing.Tracer) client.CallWrapper {
	return func(cf client.CallFunc) client.CallFunc {
		return func(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
			if ot == nil {
				ot = opentracing.GlobalTracer()
			}
			name := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
			ctx, span, err := StartSpanFromContext(ctx, ot, name)
			if err != nil {
				return err
			}
			defer span.Finish()
			return cf(ctx, node, req, rsp, opts)
		}
	}
}
878516
func NewHandler(s config.Storage) *handler {
	if s.Database == "" {
		s.Database = object.DefaultDatabase
	}
	h := &handler{
		dailInfo: &mgo.DialInfo{
			PoolLimit: 4096,
			Timeout:   time.Second,
			FailFast:  true,
			Username:  s.Username,
			Password:  s.Password,
			Addrs:     s.Address,
			Database:  s.Database,
		},
		database: s.Database,
	}
	return h
}
970541
func NewHandler(n *centrifuge.Node, c Config) *Handler {
	h := &Handler{
		node:   n,
		config: c,
	}
	return h
}
510108
func (mr *MockBuilderFactoryMockRecorder) NewBuilder(arg0, arg1 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewBuilder", reflect.TypeOf((*MockBuilderFactory)(nil).NewBuilder), arg0, arg1)
}