axe/job.go
func Enqueue(store *coal.SubStore, name string, data Model, delay time.Duration) (*Job, error) {
	// set default data
	if data == nil {
		data = bson.M{}
	}

	// get time
	now := time.Now()

	// prepare job
	job := coal.Init(&Job{
		Name:      name,
		Status:    StatusEnqueued,
		Created:   now,
		Available: now.Add(delay),
	}).(*Job)

	// marshall data
	raw, err := bson.Marshal(data)
	if err != nil {
		return nil, err
	}

	// marshall into job
	err = bson.Unmarshal(raw, &job.Data)
	if err != nil {
		return nil, err
	}

	// insert job
	err = store.C(job).Insert(job)
	if err != nil {
		return nil, err
	}

	return job, nil
}
func Enqueue(store *coal.SubStore, name string, data Model, delay time.Duration) (*Job, error) {
	// set default data
	if data == nil {
		data = bson.M{}
	}

	// get time
	now := time.Now()

	// prepare job
	job := coal.Init(&Job{
		Name:      name,
		Status:    StatusEnqueued,
		Created:   now,
		Available: now.Add(delay),
	}).(*Job)

	// marshall data
	raw, err := bson.Marshal(data)
	if err != nil {
		return nil, err
	}

	// marshall into job
	err = bson.Unmarshal(raw, &job.Data)
	if err != nil {
		return nil, err
	}

	// insert job
	err = store.C(job).Insert(job)
	if err != nil {
		return nil, err
	}

	return job, nil
}
// Enqueue will enqueue a job using the specified name and data. If a delay
// is specified the job will not be dequeued until the specified time has passed.