job/queue.go
func (q *queue) Add(tx *reform.TX, j *data.Job) error {
	logger := q.logger.Add("method", "Add", "job", j)
	tconf := q.typeConfig(j)
	if !tconf.Duplicated {
		if err := q.checkDuplicated(j, logger); err != nil {
			return err
		}
	}
	if tconf.FirstStartDelay > 0 {
		j.NotBefore = time.Now().Add(
			time.Duration(tconf.FirstStartDelay) * time.Millisecond)
	}

	j.ID = util.NewUUID()
	j.Status = data.JobActive
	j.CreatedAt = time.Now()

	db := q.db.Querier
	if tx != nil {
		db = tx.Querier
	}

	if err := db.Insert(j); err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	return nil
}
func (q *queue) Add(tx *reform.TX, j *data.Job) error {
	logger := q.logger.Add("method", "Add", "job", j)
	tconf := q.typeConfig(j)
	if !tconf.Duplicated {
		if err := q.checkDuplicated(j, logger); err != nil {
			return err
		}
	}
	if tconf.FirstStartDelay > 0 {
		j.NotBefore = time.Now().Add(
			time.Duration(tconf.FirstStartDelay) * time.Millisecond)
	}

	j.ID = util.NewUUID()
	j.Status = data.JobActive
	j.CreatedAt = time.Now()

	db := q.db.Querier
	if tx != nil {
		db = tx.Querier
	}

	if err := db.Insert(j); err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	return nil
}
// Add adds a new job to the job queue (optionally within a given transaction).