oban v0.7.0 Release Notes

Release Date: 2019-08-08 // over 4 years ago
  • โž• Added

    • [Oban] Added insert/2, insert!/2 and insert/4 as a convenient and more powerful way to insert jobs. Features such as unique jobs and the upcoming prefix support only work with insert.

    • ๐Ÿ‘ท [Oban] Add prefix support. This allows entirely isolated job queues within the same database.

    • โœ๏ธ [Oban.Worker] Compile time validation of all passed options. Catch typos and other invalid options when a worker is compiled rather than when a job is inserted for the first time.

    • ๐Ÿ‘ท [Oban.Worker] Unique job support through the unique option. Set a unique period, and optionally fields and states, to enforce uniqueness within a window of time. For example, to make a job unique by args, queue and worker for 2 minutes:

    use Oban.Worker, unique: [period: 120, fields: [:args, :queue, :worker]]

    Note, unique support relies on the use of Oban.insert/2,4.

    ๐Ÿ”„ Changed

    • ๐Ÿšš [Oban.Worker] Remove the perform/1 callback in favor of perform/2. The new perform/2 function receives the job's args, followed by the complete job struct. This new function signature makes it clear that the args are always available, and the job struct is also there when it is needed. A default perform/2 function is not generated automatically by the use macro and must be defined manually.

    This is a breaking change and all worker modules will need to be updated. Thankfully, due to the behaviour change, warnings will be emitted when you compile after the upgrade.

    If your perform functions weren't matching on the Oban.Job struct then you can migrate your workers by adding a second _job argument:

    def perform(%{"some" => args}, _job)

    If you were making use of Oban.Job metadata in perform/1 then you can move the job matching to the second argument:

    def perform(_args, %{attempt: attempt})

    See the issue that suggested this change for more details and discussion.

    • [Oban.Producer] Use send_after/3 instead of :timer.send_interval/2 to maintain scheduled dispatch. This mechanism is more accurate under system load and it prevents :poll messages from backing up for each producer.

    • [Oban.Migration] Accept a keyword list with :prefix and :version as options rather than a single version string. When a prefix is supplied the migration will create all tables, indexes, functions and triggers within that namespace. For example, to create the jobs table within a "private" prefix:

    Oban.Migrate.up(prefix: "private")