Beispiel #1
0
func (suite *BenchmarkSuite) SetUpSuite(c *C) {
	runtime.GOMAXPROCS(8)
	rand.Seed(time.Now().UTC().UnixNano())
	suite.goenv = goenv.NewGoenv("../example/config.yml", "gotesting", "../example/log/test.log")
	suite.queue1k = redismq.NewQueue(suite.goenv, "teststuff1k")
	suite.queue4k = redismq.NewQueue(suite.goenv, "teststuff4k")
	suite.consumer1k, _ = suite.queue1k.AddConsumer("testconsumer")
	suite.consumer4k, _ = suite.queue4k.AddConsumer("testconsumer")

	suite.mutliConsumer1k = make([]*redismq.Consumer, 0)
	for i := 0; i < 4; i++ {
		q := redismq.NewQueue(suite.goenv, "teststuff1k")
		c, err := q.AddConsumer("c" + strconv.Itoa(i))
		if err != nil {
			panic(err)
		}
		suite.mutliConsumer1k = append(suite.mutliConsumer1k, c)
	}
	suite.mutliConsumer4k = make([]*redismq.Consumer, 0)
	for i := 0; i < 4; i++ {
		q := redismq.NewQueue(suite.goenv, "teststuff4k")
		c, err := q.AddConsumer("c" + strconv.Itoa(i))
		if err != nil {
			panic(err)
		}
		suite.mutliConsumer4k = append(suite.mutliConsumer4k, c)
	}
}
Beispiel #2
0
func (suite *BenchmarkSuite) SetUpSuite(c *C) {
	runtime.GOMAXPROCS(8)
	rand.Seed(time.Now().UTC().UnixNano())
	suite.queue1k = redismq.NewQueue(redisURL, redisPassword, redisDb, "teststuff1k")
	suite.queue4k = redismq.NewQueue(redisURL, redisPassword, redisDb, "teststuff4k")
	suite.consumer1k, _ = suite.queue1k.AddConsumer("testconsumer")
	suite.consumer4k, _ = suite.queue4k.AddConsumer("testconsumer")

	suite.mutliConsumer1k = make([]*redismq.Consumer, 0)
	for i := 0; i < 4; i++ {
		q := redismq.NewQueue(redisURL, redisPassword, redisDb, "teststuff1k")
		c, err := q.AddConsumer("c" + strconv.Itoa(i))
		if err != nil {
			panic(err)
		}
		suite.mutliConsumer1k = append(suite.mutliConsumer1k, c)
	}
	suite.mutliConsumer4k = make([]*redismq.Consumer, 0)
	for i := 0; i < 4; i++ {
		q := redismq.NewQueue(redisURL, redisPassword, redisDb, "teststuff4k")
		c, err := q.AddConsumer("c" + strconv.Itoa(i))
		if err != nil {
			panic(err)
		}
		suite.mutliConsumer4k = append(suite.mutliConsumer4k, c)
	}
}
Beispiel #3
0
func (suite *TestSuite) SetUpSuite(c *C) {
	runtime.GOMAXPROCS(8)
	rand.Seed(time.Now().UTC().UnixNano())
	suite.goenv = goenv.NewGoenv("../example/config.yml", "gotesting", "../example/log/test.log")
	suite.queue = redismq.NewQueue(suite.goenv, "teststuff")
	suite.consumer, _ = suite.queue.AddConsumer("testconsumer")
}
Beispiel #4
0
func write(queue string) {
	testQueue := redismq.NewQueue("localhost:6379", "", 9, queue)
	payload := randomString(1024 * 1) //adjust for size
	for {
		testQueue.Put(payload)
	}
}
Beispiel #5
0
func write() {
	goenv := goenv.DefaultGoenv()
	testQueue := redismq.NewQueue(goenv, "example")
	payload := randomString(1024 * 1) //adjust for size
	for {
		testQueue.Put(payload)
	}
}
Beispiel #6
0
func read(queue, prefix string) {
	testQueue := redismq.NewQueue("localhost:6379", "", 9, queue)
	consumer, err := testQueue.AddConsumer("testconsumer" + prefix)
	if err != nil {
		panic(err)
	}
	consumer.ResetWorking()
	for {
		p, err := consumer.MultiGet(200)
		if err != nil {
			log.Println(err)
			continue
		}
		p[len(p)-1].MultiAck()
	}
}
Beispiel #7
0
func read(prefix string) {
	goenv := goenv.DefaultGoenv()
	testQueue := redismq.NewQueue(goenv, "example")
	consumer, err := testQueue.AddConsumer("testconsumer" + prefix)
	if err != nil {
		panic(err)
	}
	consumer.ResetWorking()
	for {
		p, err := consumer.Get()
		if err != nil {
			log.Println(err)
			continue
		}
		err = p.Ack()
	}
}
Beispiel #8
0
func main() {
	testQueue := redismq.NewQueue("localhost:6379", "", 9, "clicks")
	for i := 0; i < 10; i++ {
		testQueue.Put("testpayload")
	}
	consumer, err := testQueue.AddConsumer("testconsumer")
	if err != nil {
		panic(err)
	}
	for i := 0; i < 10; i++ {
		p, err := consumer.Get()
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println(p.CreatedAt)
		err = p.Ack()
		if err != nil {
			fmt.Println(err)
		}
	}
}
Beispiel #9
0
func main() {
	goenv := goenv.DefaultGoenv()
	testQueue := redismq.NewQueue(goenv, "clicks")
	for i := 0; i < 10; i++ {
		testQueue.Put("testpayload")
	}
	consumer, err := testQueue.AddConsumer("testconsumer")
	if err != nil {
		panic(err)
	}
	for i := 0; i < 10; i++ {
		p, err := consumer.Get()
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println(p.CreatedAt)
		err = p.Ack()
		if err != nil {
			fmt.Println(err)
		}
	}
}
Beispiel #10
0
// should handle multiple queues
func (suite *TestSuite) TestSecondQueue(c *C) {
	secondQueue := redismq.NewQueue(redisURL, redisPassword, redisDb, "teststuff2")
	secondConsumer, err := secondQueue.AddConsumer("testconsumer")
	c.Assert(err, Equals, nil)

	secondQueue.ResetInput()
	secondQueue.ResetFailed()
	secondConsumer.ResetWorking()
	c.Check(suite.queue.Put("testpayload"), Equals, nil)
	c.Check(secondQueue.Put("testpayload2"), Equals, nil)

	p, err := suite.consumer.Get()
	c.Assert(err, Equals, nil)
	c.Check(p.Payload, Equals, "testpayload")

	p2, err := secondConsumer.Get()
	c.Assert(err, Equals, nil)
	c.Check(p2.Payload, Equals, "testpayload2")

	secondQueue.ResetInput()
	secondQueue.ResetFailed()
	secondConsumer.ResetWorking()
}
Beispiel #11
0
func (suite *TestSuite) SetUpTest(c *C) {
	suite.redisClient.FlushDb()
	suite.queue = redismq.NewQueue(redisURL, redisPassword, redisDb, "teststuff")
	suite.consumer, _ = suite.queue.AddConsumer("testconsumer")
}