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

Accept a job struct as the argument to perform/1 #32

Merged
merged 1 commit into from Jul 17, 2019

Conversation

@sorentwo
Copy link
Owner

commented Jul 17, 2019

The perform/1 function now receives an Oban.Job struct as the sole argument, calling perform/1 again with only the args map if no clause catches the struct. This allows workers to use any attribute of the job to customize behaviour, e.g. the number of attempts or when a job was inserted into the database.

The implementation is entirely backward compatible, provided workers are defined with the use macro. Workers that implement the Oban.Worker behaviour manually will need to change the signature of perform/1 to accept a job struct.

Addresses the first part of #27


I'm opening this as a PR to get some feedback on the implementation and documentation.

/cc @andykent

@andykent

This comment has been minimized.

Copy link

commented Jul 17, 2019

Looks great and I think the documentation is clear. I agree that this is a good first step.

Accept a job struct as the argument to perform/1
The `perform/1` function now receives an `Oban.Job` struct as the sole
argument, calling `perform/1` again with only the `args` map if no
clause catches the struct. This allows workers to use any attribute of
the job to customize behaviour, e.g. the number of attempts or when a
job was inserted into the database.

The implementation is entirely backward compatible, provided workers are
defined with the `use` macro. Workers that implement the `Oban.Worker`
behaviour manually will need to change the signature of `perform/1` to
accept a job struct.

@sorentwo sorentwo force-pushed the feature/perform-job-struct branch from 7de2b21 to a01840b Jul 17, 2019

@sorentwo sorentwo merged commit c0f6788 into master Jul 17, 2019

1 check was pending

ci/circleci: build CircleCI is running your tests
Details

@sorentwo sorentwo deleted the feature/perform-job-struct branch Jul 17, 2019

@sorentwo

This comment has been minimized.

Copy link
Owner Author

commented Jul 17, 2019

@andykent Thanks for taking a look 💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.