Esempio n. 1
0
func NewDeliveryWorker(v1workflow process, v2workflow workflow, config DeliveryWorkerConfig) DeliveryWorker {
	logger := config.Logger.Session("worker", lager.Data{"worker_id": config.ID})

	worker := DeliveryWorker{
		V1Process:              v1workflow,
		V2Workflow:             v2workflow,
		uaaHost:                config.UAAHost,
		logger:                 logger,
		database:               config.Database,
		strategyDeterminer:     config.StrategyDeterminer,
		deliveryFailureHandler: config.DeliveryFailureHandler,
		messageStatusUpdater:   config.MessageStatusUpdater,
	}
	worker.Worker = gobble.NewWorker(config.ID, config.Queue, worker.Deliver)

	return worker
}
Esempio n. 2
0
		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)
			}