Skip to content

Enforce unique job keys #50

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

Merged
merged 5 commits into from
Jan 22, 2025
Merged

Enforce unique job keys #50

merged 5 commits into from
Jan 22, 2025

Conversation

raphael
Copy link
Member

@raphael raphael commented Jan 21, 2025

This PR does a few of things:

  1. It ensures calling Get on a replicated map for a key that was set with an empty string returns "", true
  2. It adds a new SetIfNotExists methods to replicated maps that will set a value only if it isn't already in the map.
  3. It ensures the pool node DispatchJob method returns the new ErrJobExists error when attempting to queue a job with a key that already exists.

It was previously the responsibility of the client to ensure no two calls to DispatchJob used the same key, now the pool package enforces it.

Setting an empty string value then calling Get now
returns empty string and true.

Also remove the need for using a sentinel value ("*")
when doing a reset.
This commit does a couple of things:
1. It adds a new `SetIfNotExists` methods to replicated maps that will set a value only if it isn't already in the map.
2. It ensures the pool node `DispatchJob` method returns an the new `ErrJobExists` error when attempting to queue a job with a key that already exists.

It was previously the responsibility of the client to ensure no two calls to DispatchJob used the same key, now the pool package enforces it.
So that we can ensure decoding all the parts in Go.
This replaces the previous algo that was using : to separate key and values
which was not working if a key or a value also contained :.
@raphael raphael merged commit a19129a into main Jan 22, 2025
4 checks passed
@raphael raphael deleted the unique_job_keys branch January 22, 2025 20:54
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.

1 participant