// Register injects a new service into the node's stack. The service created by
// the passed constructor must be unique in its type with regard to sibling ones.
180145
func (n *Node) Register(constructor ServiceConstructor) error {
	n.lock.Lock()
	defer n.lock.Unlock()

	if n.server != nil {
		return ErrNodeRunning
	}
	n.serviceFuncs = append(n.serviceFuncs, constructor)
	return nil
}
199519
func (a *Module) Register(p string, v interface{}, methods ...string) *Module {
	if len(methods) < 1 {
		methods = append(methods, "GET")
	}
	a.Application.URLBuilder.Set(v)
	h := a.Core.ValidHandler(v)
	a.Router().Match(methods, p, func(ctx echo.Context) error {
		if c, y := ctx.(Initer); y {
			if err := c.Init(ctx); err != nil {
				return err
			}
		}
		return h.Handle(ctx)
	})
	return a
}
948597
func Register(servicer Servicer, botToken string) {
	//jobs.Config.Db.Address="192.168.1.101:6379"

	service := servicer.Service()
	if service.DefaultOAuth1 != nil {
		if service.DefaultOAuth1.AccessTokenReceiver == nil {
			err := errors.New("OAuth1 need an AccessTokenReceiver func to be specified\n")
			panic(err.Error())
		}
		service.DefaultBaseURL = *URLMustParse(service.DefaultOAuth1.AccessTokenURL)

		//mongoSession.DB(mongo.Database).C("users").EnsureIndex(mgo.Index{Key: []string{"settings." + service.Name + ".oauth_redirect_token"}})
	} else if service.DefaultOAuth2 != nil {
		service.DefaultBaseURL = *URLMustParse(service.DefaultOAuth2.Endpoint.AuthURL)
	}
	service.DefaultBaseURL.Path = ""
	service.DefaultBaseURL.RawPath = ""
	service.DefaultBaseURL.RawQuery = ""

	services[service.Name] = service

	if len(service.Jobs) > 0 || service.OAuthSuccessful != nil {
		if service.JobsPool == 0 {
			service.JobsPool = 1
		}
		pool, err := jobs.NewPool(&jobs.PoolConfig{
			Key:        "_" + service.Name,
			NumWorkers: service.JobsPool,
			BatchSize:  Config.TGPoolBatchSize,
		})
		if err != nil {
			log.Panicf("Can't create jobs pool: %v\n", err)
		} else {
			pool.SetMiddleware(beforeJob)
			pool.SetAfterFunc(afterJob)
		}

		//log.Infof("%s: workers pool [%d] is ready", service.Name, service.JobsPool)

		jobsPerService[service.Name] = make(map[string]*jobs.Type)

		if service.OAuthSuccessful != nil {
			service.Jobs = append(service.Jobs, Job{
				service.OAuthSuccessful, 10, JobRetryFibonacci,
			})
		}

		if len(service.Modules) > 0 {
			for _, module := range service.Modules {
				service.Actions = append(service.Actions, module.Actions...)
				service.Jobs = append(service.Jobs, module.Jobs...)
			}
		}

		for _, job := range service.Jobs {
			handlerType := reflect.TypeOf(job.HandlerFunc)
			m := make([]interface{}, handlerType.NumIn())

			for i := 0; i < handlerType.NumIn(); i++ {
				argType := handlerType.In(i)
				if argType.Kind() == reflect.Ptr {
					//argType = argType.Elem()
				}

				if argType.Kind() == reflect.Interface {
					gob.Register(reflect.Zero(argType))
				} else {
					gob.Register(reflect.Zero(argType).Interface())
				}
				m[i] = reflect.Zero(argType)
			}
			gob.Register(m)

			jobName := service.getShortFuncPath(job.HandlerFunc)

			jobType, err := jobs.RegisterTypeWithPoolKey(jobName, "_"+service.Name, job.Retries, job.HandlerFunc)
			if err != nil {
				fmt.Errorf("RegisterTypeWithPoolKey '%s', for %s: %s", jobName, service.Name, err.Error() )
			} else {
				jobsPerService[service.Name][jobName] = jobType
			}

		}

		rootPackagePath := reflect.TypeOf(servicer).PkgPath()
		service.rootPackagePath = rootPackagePath

		log.Debugf("RootPackagePath of %s is %s", service.Name, rootPackagePath)

		go func(pool *jobs.Pool, service *Service) {
			time.Sleep(time.Second * 5)

			err = pool.Start()

			if err != nil {
				log.Panicf("Can't start jobs pool: %v\n", err)
			}
			log.Infof("%s service: workers pool [%d] started", service.Name, service.JobsPool)

		}(pool, service)

	}

	if len(service.Actions) > 0 {
		for _, actionFunc := range service.Actions {
			actionFuncType := reflect.TypeOf(actionFunc)
			m := make([]interface{}, actionFuncType.NumIn())

			for i := 0; i < actionFuncType.NumIn(); i++ {
				argType := actionFuncType.In(i)
				if argType.Kind() == reflect.Ptr {
					//argType = argType.Elem()
				}

				gob.Register(reflect.Zero(argType).Interface())
			}
			gob.Register(m)
			actionFuncs[service.getShortFuncPath(actionFunc)] = actionFunc
		}
	}
	if botToken == "" {
		return
	}

	err := service.registerBot(botToken)
	if err != nil {
		log.WithError(err).WithField("token", botToken).Panic("Can't register the bot")
	}

	if service.Worker != nil {
		go SeviceWorkerAutorespawnGoroutine(service)
	}
	// todo: here is possible bug if service just want to use inline keyboard callbacks via setCallbackAction
	if service.TGNewMessageHandler == nil && service.TGInlineQueryHandler == nil {
		return
	}

}
619511
func (d *Dispatcher) Register(rs []transport.Procedure) {
	procedures := make([]transport.Procedure, 0, len(rs))

	for _, r := range rs {
		switch r.HandlerSpec.Type() {
		case transport.Unary:
			h := middleware.ApplyUnaryInbound(r.HandlerSpec.Unary(),
				d.inboundMiddleware.Unary)
			r.HandlerSpec = transport.NewUnaryHandlerSpec(h)
		case transport.Oneway:
			h := middleware.ApplyOnewayInbound(r.HandlerSpec.Oneway(),
				d.inboundMiddleware.Oneway)
			r.HandlerSpec = transport.NewOnewayHandlerSpec(h)
		case transport.Streaming:
			h := middleware.ApplyStreamInbound(r.HandlerSpec.Stream(),
				d.inboundMiddleware.Stream)
			r.HandlerSpec = transport.NewStreamHandlerSpec(h)
		default:
			panic(fmt.Sprintf("unknown handler type %q for service %q, procedure %q",
				r.HandlerSpec.Type(), r.Service, r.Name))
		}

		procedures = append(procedures, r)
		d.log.Info("Registration succeeded.", zap.Object("registeredProcedure", r))
	}

	d.table.Register(procedures)
}
1264845
func (h *HandlerService) Register(comp component.Component, opts []component.Option) error {
	s := component.NewService(comp, opts)

	if _, ok := h.services[s.Name]; ok {
		return fmt.Errorf("handler: service already defined: %s", s.Name)
	}

	if err := s.ExtractHandler(); err != nil {
		return err
	}

	// register all handlers
	h.services[s.Name] = s
	for name, handler := range s.Handlers {
		handlers[fmt.Sprintf("%s.%s", s.Name, name)] = handler
	}
	return nil
}
1212221
func (rs *Resources) Register(r facade.Resource) string {
	rs.mu.Lock()
	defer rs.mu.Unlock()
	rs.maxId++
	id := strconv.FormatUint(rs.maxId, 10)
	rs.resources[id] = r
	rs.stack = append(rs.stack, id)
	logger.Tracef("registered unnamed resource: %s", id)
	return id
}
903856
func (r *Registrar) Register() {
	r.Lock()
	defer r.Unlock()

	if r.quitc != nil {
		return // Already in the registration loop.
	}

	if err := r.conn.RegisterInstance(r.instance); err != nil {
		r.logger.Log("during", "Register", "err", err)
	}

	r.quitc = make(chan chan struct{})
	go r.loop()
}
98953
func (c *Collection) Register(fns ...func(DB) error) error {
	return c.register(false, fns...)
}
914278
func (p *Registrar) Register() {
	if err := p.client.Register(p.registration); err != nil {
		p.logger.Log("err", err)
	} else {
		p.logger.Log("action", "register")
	}
}
1353416
func Register(storeType string, provider StoreProvider) {
	registryMu.Lock()
	defer registryMu.Unlock()
	if _, ok := storeProviders[storeType]; ok {
		panic(fmt.Sprintf("Cannot provide duplicate store %q", storeType))
	}
	storeProviders[storeType] = provider
}
1355846
func (f *Factory) Register(componentName string, constructor Constructor) error {
	if _, exists := f.registry[componentName]; exists {
		return fmt.Errorf("Registry error: component '%s' already registered", componentName)
	}
	f.registry[componentName] = registryEntry{
		Constructor: constructor,
		Info: ComponentInfo{
			Name: componentName,
		},
	}
	return nil
}
68759
func (r *PrefixedRegistry) Register(name string, metric interface{}) error {
	realName := r.prefix + name
	return r.underlying.Register(realName, metric)
}
432951
func Register(name string, factory ValidatorFactory) {
	typesMu.Lock()
	defer typesMu.Unlock()
	if factory == nil {
		panic("authmethod: Register factory is nil for type " + name)
	}
	if _, dup := types[name]; dup {
		panic("authmethod: Register called twice for type " + name)
	}
	types[name] = factory
}
1004695
func Register(plugins *admission.Plugins) {
	plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) {
		serviceAccountAdmission := NewServiceAccount()
		return serviceAccountAdmission, nil
	})
}
527035
func (ir *generatorRegistry) register(g InterfaceGeneratorFunc) {
	val, ok := g().(InterfaceMarshaler)
	if !ok {
		panic("Implementation of the interface must fulfilled InterfaceMarshaler")
	}
	key := val.MarshalID()

	ir.generators[key] = g
}
447192
func Register(name string, auth handleFunc) {
	serversTex.Lock()
	servers[name] = auth
	serversTex.Unlock()
}
967846
func (d *dispatcher) Register(c StreamType, h Handler) {
	d.handlers[c] = h
}