Exemple #1
0
func newPushRedisDB(c *DatabaseConfig) (*PushRedisDB, error) {
	if c == nil {
		return nil, errors.New("Invalid Database Config")
	}
	if strings.ToLower(c.Engine) != "redis" {
		return nil, errors.New("Unsupported Database Engine")
	}

	if c.Host == "" {
		c.Host = "localhost"
	}
	if c.Port <= 0 {
		c.Port = 6379
	}
	if c.Name == "" {
		c.Name = "0"
	}

	db, err := strconv.ParseInt(c.Name, 10, 64)
	if err != nil {
		db = 0
	}
	client := redis3.NewClient(&redis3.Options{
		Addr:     fmt.Sprintf("%s:%d", c.Host, c.Port),
		Password: c.Password,
		DB:       db,
	})

	ret := new(PushRedisDB)
	ret.client = client
	ret.psm = c.PushServiceManager
	if ret.psm == nil {
		ret.psm = push.GetPushServiceManager()
	}
	return ret, nil
}
Exemple #2
0
func InstallADM() {
	psm := push.GetPushServiceManager()
	psm.RegisterPushServiceType(newADMPushService())
}