Exemple #1
0
func (m *Mother) Queue() gobble.QueueInterface {
	env := NewEnvironment()

	return gobble.NewQueue(m.GobbleDatabase(), gobble.Config{
		WaitMaxDuration: time.Duration(env.GobbleWaitMaxDuration) * time.Millisecond,
	})
}
Exemple #2
0
		queue                 *gobble.Queue
		worker                gobble.Worker
		callbackWasCalledWith gobble.Job
		callback              func(*gobble.Job)
		database              *gobble.DB
	)

	BeforeEach(func() {
		TruncateTables()

		callback = func(job *gobble.Job) {
			callbackWasCalledWith = *job
		}
		database = gobble.NewDatabase(sqlDB)

		queue = gobble.NewQueue(database, gobble.Config{})
		worker = gobble.NewWorker(1, queue, callback)
	})

	AfterEach(func() {
		queue.Close()
	})

	Describe("Perform", func() {
		It("reserves a job, performs the callback, and then dequeues the completed job", func() {
			job, err := queue.Enqueue(gobble.Job{
				Payload: "the-payload",
			})
			if err != nil {
				panic(err)
			}
Exemple #3
0
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Queue", func() {
	var (
		queue    *gobble.Queue
		database *gobble.DB
	)

	BeforeEach(func() {
		TruncateTables()
		database = gobble.NewDatabase(sqlDB)

		queue = gobble.NewQueue(database, gobble.Config{
			WaitMaxDuration: 50 * time.Millisecond,
		})
	})

	AfterEach(func() {
		queue.Close()
	})

	Describe("Enqueue", func() {
		It("sticks the job in the database table", func() {
			job := gobble.NewJob(map[string]bool{
				"testing": true,
			})

			job, err := queue.Enqueue(job)
			Expect(err).NotTo(HaveOccurred())