Skip to content

Conversation

@brandur
Copy link
Contributor

@brandur brandur commented Apr 28, 2024

Implement unique job insertion in a way that's compatible with the main
Go library. Unique opts live on insert opts just like in Go, and we
copy as much of its API as possible including return result.

insert_res = client.insert(args, insert_opts: River::InsertOpts.new(
  unique_opts: River::UniqueOpts.new(
    by_args: true,
    by_period: 15 * 60,
    by_queue: true,
    by_state: [River::JOB_STATE_AVAILABLE]
  )
)

# contains either a newly inserted job, or an existing one if insertion was skipped
insert_res.job

# true if insertion was skipped
insert_res.unique_skipped_as_duplicated

@brandur brandur force-pushed the brandur-unique-jobs branch from 0bcf50d to 76db952 Compare April 28, 2024 03:32
Implement unique job insertion in a way that's compatible with the main
Go library. Unique opts live on insert opts just like in Go, and we
copy as much of its API as possible including return result.

    insert_res = client.insert(args, insert_opts: River::InsertOpts.new(
      unique_opts: River::UniqueOpts.new(
        by_args: true,
        by_period: 15 * 60,
        by_queue: true,
        by_state: [River::JOB_STATE_AVAILABLE]
      )
    )

    # contains either a newly inserted job, or an existing one if insertion was skipped
    insert_res.job

    # true if insertion was skipped
    insert_res.unique_skipped_as_duplicated
@brandur brandur force-pushed the brandur-unique-jobs branch from 76db952 to 32af5cf Compare April 28, 2024 03:34
@brandur brandur merged commit 683f098 into master Apr 28, 2024
@brandur brandur deleted the brandur-unique-jobs branch April 28, 2024 03:36
brandur added a commit that referenced this pull request Apr 28, 2024
Prepare release `v0.3.0` which largely includes unique jobs from #10.
Also tweak the publishing instructions, which were once again, still
somewhat wrong (building a gem doesn't lead directly to an updated
`Gemfile.lock`).
@brandur brandur mentioned this pull request Apr 28, 2024
brandur added a commit that referenced this pull request Apr 28, 2024
Prepare release `v0.3.0` which largely includes unique jobs from #10.
Also tweak the publishing instructions, which were once again, still
somewhat wrong (building a gem doesn't lead directly to an updated
`Gemfile.lock`).
brandur added a commit that referenced this pull request Apr 28, 2024
Follows up #10 with a few minor reworks to the test suite. Prefer
`job_args` over `args` as a variable name, and add a `job_args_to_row`
helper for convenience.
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