Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repetitive jobs (put job back to queue in handler) #158

Open
alizdavoodi opened this issue May 25, 2020 · 0 comments
Open

Repetitive jobs (put job back to queue in handler) #158

alizdavoodi opened this issue May 25, 2020 · 0 comments

Comments

@alizdavoodi
Copy link

I'm trying to implement a password rotation mechanism for our app,
in the job handler, I'm trying to put the job back to queue and run in a specific interval, so when user created we'll put the password in the queue for rotation in 500 secs

_, err = con.Enqueuer.EnqueueIn("password_rotation", 500, work.Q{"Username": u.Name, "Password": randpass})

The handler it looks like this:

func sampleHandler(job *work.Job) error {

	fmt.Printf("%+v", job.Args)

	//Logic for new password

	_, err := enqueuer.EnqueueIn("password_rotation", 500, work.Q{"Username": job.ArgString("Username"), "Password": NewPassword() })

	if err != nil {
		return err
	}

	return nil
}

pool.Job("password_rotation", sampleHandler)

Is this a good idea? Do you have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant