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

:fake mode does not respect uniqueness settings #492

Open
nicnilov opened this issue Jul 8, 2024 · 2 comments
Open

:fake mode does not respect uniqueness settings #492

nicnilov opened this issue Jul 8, 2024 · 2 comments

Comments

@nicnilov
Copy link

nicnilov commented Jul 8, 2024

Here is an example:

args = ["arg1", "arg2"]
unique_token = "my_unique_token"

Exq.enqueue(Exq, "queue", MyWorker, args, unique_token: unique_token, unique_for: 5)
Exq.enqueue(Exq, "queue", MyWorker, args, unique_token: unique_token, unique_for: 5)
Exq.enqueue(Exq, "queue", MyWorker, args, unique_token: unique_token, unique_for: 5)

Expected result: A single instance of the job is returned by Exq.Mock.jobs().
Actual result: Three instances of the job get returned by Exq.Mock.jobs().

Additionally, the returned jobs have their uniqueness attributes set to nil while it might be expected those would carry at least some of the supplied values:

[
  %Exq.Support.Job{
    error_message: nil,
    error_class: nil,
    retried_at: nil,
    failed_at: nil,
    retry: false,
    retry_count: 0,
    processor: nil,
    queue: "queue",
    class: MyWorker,
    args: ["arg1", "arg2"],
    jid: "7789467e-dc08-4af4-a006-6ad9e5113f21",
    finished_at: nil,
    enqueued_at: ~U[2024-07-08 11:31:22.577966Z],
    unique_for: nil,
    unique_until: nil,
    unique_token: nil,
    unlocks_at: nil
  },
  ...
]

Exq config:

In config/config.exs:

config :exq,
  name: Exq,
  ...
  middleware: [Exq.Middleware.Stats, Exq.Middleware.Job, Exq.Middleware.Manager,
               Exq.Middleware.Unique, Exq.Middleware.Logger]

In config/test.exs:

config :exq,
  queue_adapter: Exq.Adapters.Queue.Mock,
  start_on_application: false

In test_helper.exs:

Exq.Mock.start_link(mode: :fake)

Changing the Mock config to mode: :inline correctly enqueues just a single instance of worker.

@ananthakumaran
Copy link
Collaborator

This is one of those things that is not supported by a fake adapter. I am surprised inline is working, only Redis adapter is supposed to work correctly.

@nicnilov
Copy link
Author

nicnilov commented Jul 8, 2024

Is this by design then and not going to be fixed?

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

2 participants