Ejemplo n.º 1
0
func TestQueue(t *testing.T) {
	q := gouda.NewQ(100)
	wg := new(sync.WaitGroup)
	queue, _ := gouda.NewQueue(q)

	wg.Add(1)
	go func(p gouda.Producer) {
		for i := 1; i < 5; i++ {
			p.Pub([]byte("we can do it."))
			//		time.Sleep(time.Second * 1)
		}
		p.Pub([]byte("EOF"))
		wg.Done()
	}(queue)
	wg.Add(1)
	go func(c gouda.Consumer) {
		for {
			msg, _, _ := c.Sub()
			if string(msg) == "EOF" {
				t.Log(string(msg))
				break
			}
			t.Log(string(msg))
		}
		wg.Done()
	}(queue)
	wg.Wait()
}
Ejemplo n.º 2
0
func TestPQueue(t *testing.T) {
	t.Log("what's wrong")
	q := gouda.NewQ(100)
	t.Log(q)
	wg := new(sync.WaitGroup)
	queue, err := gouda.NewPQueue(q, "./home/back.back")
	if queue != nil {
		t.Log(queue)
	}
	if err != nil {
		t.Error(err.Error())
		return
	}

	t.Log(queue)

	if err != nil {
		t.Error("Get queue error")
	}
	wg.Add(1)
	go func(p gouda.Producer) {
		for i := 1; i < 5; i++ {
			p.Pub([]byte("we can do it."))
			time.Sleep(time.Second * 1)
		}
		queue.Pub([]byte("EOF"))
		wg.Done()
	}(queue)
	wg.Add(1)
	go func(c gouda.Consumer) {
		for {
			msg, _, _ := c.Sub()
			if string(msg) == "EOF" {
				t.Log(string(msg))
				break
			}
			t.Log(string(msg))
		}
		wg.Done()
	}(queue)
	wg.Wait()
}
Ejemplo n.º 3
0
func TestQCreate(t *testing.T) {
	queue := gouda.NewQ(10)
	t.Log(queue)
}