//Register a database, should be call at the beginning of the application.
516608
func Register(driverName, driverSourceName, databaseName string, dialect Dialect) {
	driverSource = driverSourceName
	dbName = databaseName
	if db == nil {
		var err error
		var database *sql.DB
		database, err = sql.Open(driverName, driverSource)
		if err != nil {
			panic(err)
		}
		RegisterWithDb(driverName, database, dialect)
	}
}
425846
func Register(name string, factory acl.Factory) {
	mu.Lock()
	defer mu.Unlock()
	if _, ok := acls[name]; ok {
		panic(fmt.Sprintf("register a registered key: %s", name))
	}
	acls[name] = factory
}
272614
func (s *Restore) Registration(idx uint64, req *structs.RegisterRequest) error {
	if err := s.store.ensureRegistrationTxn(s.tx, idx, req); err != nil {
		return err
	}
	return nil
}
882635
func (s *DB) DB() *sql.DB {
	db, _ := s.db.(*sql.DB)
	return db
}
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")
	}
}
1351334
func Register(r types.ConfigRegistration) {
	registrationsRWL.Lock()
	defer registrationsRWL.Unlock()
	for x, rr := range registrations {
		if rr.Name() == r.Name() {
			registrations[x] = r
			return
		}
	}
	registrations = append(registrations, r)
}
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
}
793159
func (s *Server) Register(id interface{}, f interface{}) {
	switch f.(type) {
	case func([]interface{}):
	case func([]interface{}) interface{}:
	case func([]interface{}) []interface{}:
	default:
		panic(fmt.Sprintf("function id %v: definition of function is invalid", id))
	}

	if _, ok := s.functions[id]; ok {
		panic(fmt.Sprintf("function id %v: already registered", id))
	}

	s.functions[id] = f
}
419259
func (p *roundRobinResourcePool) Register(resourceLocation string) error {
	if resourceLocation == "" {
		return errors.New("Registering invalid resource location")
	}

	p.rwMutex.Lock()
	defer p.rwMutex.Unlock()

	if p.isLameDuck {
		return errors.Newf(
			"Cannot register %s to lame duck resource pool",
			resourceLocation)
	}

	for _, locPool := range p.pools {
		if locPool.ResourceLocation == resourceLocation {
			return nil
		}
	}

	pool := p.createPool(p.options)
	if err := pool.Register(resourceLocation); err != nil {
		return err
	}

	p.pools = append(
		p.pools,
		&ResourceLocationPool{
			ResourceLocation: resourceLocation,
			Pool:             pool,
		})

	shuffle(p.pools)
	return nil
}
682107
func init() {
	// Registry archci database models.
	models.RegisterModels()

	// Initialize database with environment variables.
	server := ""
	username := "root"
	password := "root"
	database := "mysql"

	if os.Getenv(ENV_MYSQL_SERVER) != "" {
		server = os.Getenv(ENV_MYSQL_SERVER)
	}
	if os.Getenv(ENV_MYSQL_USERNAME) != "" {
		username = os.Getenv(ENV_MYSQL_USERNAME)
	}
	if os.Getenv(ENV_MYSQL_PASSWORD) != "" {
		password = os.Getenv(ENV_MYSQL_PASSWORD)
	}
	if os.Getenv(ENV_MYSQL_DATABASE) != "" {
		database = os.Getenv(ENV_MYSQL_DATABASE)
	}

	// The datasource looks like "root:root@/archci?charset=utf8".
	DATASOURCE := username + ":" + password + "@" + server + "/" + database + "?charset=utf8"
	fmt.Println("Connect to database with " + DATASOURCE)

	orm.RegisterDriver(MYSQL_DRIVER, orm.DR_MySQL)
	orm.RegisterDataBase("default", MYSQL_DRIVER, DATASOURCE, 30)
	orm.RunSyncdb("default", false, true)
}
381498
func (mc MongoClient) AddRegistration(r contract.Registration) (string, error) {
	s := mc.getSessionCopy()
	defer s.Close()

	var mapped models.Registration
	id, err := mapped.FromContract(r)
	if err != nil {
		return "", err
	}

	mapped.TimestampForAdd()

	if err = s.DB(mc.database.Name).C(db.ExportCollection).Insert(mapped); err != nil {
		return "", errorMap(err)
	}
	return id, nil
}
178494
func (r *Registry) Register(
	puID string,
	pu *policy.PUInfo,
	puContext *pucontext.PUContext,
	secrets secrets.Secrets,
) (*ServiceContext, error) {

	r.Lock()
	defer r.Unlock()

	sctx := &ServiceContext{
		PU:                    pu,
		PUContext:             puContext,
		dependentServiceCache: servicecache.NewTable(),
		RootCA:                [][]byte{},
	}

	// Delete all old references first. Since the registry is locked
	// nobody will be affected.
	r.indexByPort.DeleteByID(puID, true)
	r.indexByPort.DeleteByID(puID, false)

	if err := r.updateDependentServices(sctx); err != nil {
		return nil, err
	}

	if err := r.updateExposedServices(sctx, secrets); err != nil {
		return nil, err
	}

	r.indexByName[puID] = sctx

	return sctx, nil
}
157508
func (t *connTable) Register(ck ckey, matchedRule *Rule, srcIP, srcPort string, targetPort layers.TCPPort) {
	t.mtx.Lock()
	defer t.mtx.Unlock()

	if _, ok := t.table[ck]; ok {
		// TODO: wut?
	} else {
		logger.Debugf("[contable] registering %s:%s->%d", srcIP, srcPort, targetPort)

		t.table[ck] = &Metadata{
			Added:      time.Now(),
			Rule:       matchedRule,
			TargetPort: targetPort,
			//TargetIP:   targetIP,
		}
	}
}
524710
func InitDB(b bool) DBConfiguration {
	return func(c *CyclePDB) error {
		c.initdb = b
		return nil
	}
}
1318838
func Register(name string, initFunc InitFunc) error {
	if middlewares == nil {
		middlewares = make(map[string]InitFunc)
	}
	if _, exists := middlewares[name]; exists {
		return fmt.Errorf("name already registered: %s", name)
	}

	middlewares[name] = initFunc

	return nil
}
1298155
func Register(r *Registration) {
	register.Lock()
	defer register.Unlock()
	if r.Type == "" {
		panic(ErrNoType)
	}
	if r.ID == "" {
		panic(ErrNoPluginID)
	}

	var last bool
	for _, requires := range r.Requires {
		if requires == "*" {
			last = true
		}
	}
	if last && len(r.Requires) != 1 {
		panic(ErrInvalidRequires)
	}

	register.r = append(register.r, r)
}
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
	}

}