Skip to content

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

Merged
sorentwo merged 1 commit intomasterfrom
feature/perform-job-struct
Jul 17, 2019
Merged

Accept a job struct as the argument to perform/1#32
sorentwo merged 1 commit intomasterfrom
feature/perform-job-struct

Conversation

@sorentwo
Copy link
Copy Markdown
Member

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
Copy link
Copy Markdown

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

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 Compare July 17, 2019 20:10
@sorentwo sorentwo merged commit c0f6788 into master Jul 17, 2019
@sorentwo sorentwo deleted the feature/perform-job-struct branch July 17, 2019 20:11
@sorentwo
Copy link
Copy Markdown
Member Author

@andykent Thanks for taking a look 💛

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

Successfully merging this pull request may close these issues.

2 participants