Esempio n. 1
0
func getQueues() (qs []string) {
	set := map[string]bool{}
	rd := rdc.Connect(rdc.Configuration{})
	// resque* to optionally support custom namespaces
	for _, v := range rd.Command("keys", pattern).Values() {
		set[v.String()] = true
	}
	// this will pull old queues that have files left
	filepath.Walk(dataDir, func(p string, fi os.FileInfo, e error) error {
		if !fi.IsDir() && fi.Mode()&os.ModeSymlink != os.ModeSymlink {
			p = filepath.Base(p)
			if match, _ := filepath.Match(pattern, p); match {
				e := filepath.Ext(p)
				p = strings.Replace(p, e, "", 1) // remove extension
				// fmt.Println(p, "match")
				set[p] = true
			}
		}
		return e
	})
	for k, _ := range set {
		qs = append(qs, k)
	}
	return
}
Esempio n. 2
0
// return top json blob from redis queue
func fromRedis(q string) (s string) {
	rd := rdc.Connect(rdc.Configuration{})
	switch rightpush {
	case true: // rightpush
		s = rd.Command("lindex", q, 0).Value().String()
	case false: // leftpush
		s = rd.Command("lindex", q, -1).Value().String()
	}
	return
}
Esempio n. 3
0
func TestTcglRedisConnect(t *testing.T) {
	tcglRedisClient = redis.Connect(redis.Configuration{Address: fmt.Sprintf("%s:%d", host, port)})

	res := tcglRedisClient.Command("PING")

	if res.Error() != nil {
		t.Fatalf("Command failed: %v", res.Error())
	}

	if res.ValueAsString() != "PONG" {
		t.Fatalf("Failed")
	}
}
Esempio n. 4
0
func NewRedisStore(c redis.Configuration) (store *RedisStore) {
	return &RedisStore{
		db: redis.Connect(c),
	}
}