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

Support key parameter in $api->mutex #339

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/Myriad/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ method config ($key) {

async method mutex (@args) {
my ($code) = extract_by { ref($_) eq 'CODE' } @args;
# `name` is used for a shared mutex across services
my $name = @args % 2 ? shift(@args) : $service_name;
my %args = @args;
$log->infof('Service = %s', "$service");
# `key` is used for a suffix for a specific service
my $suffix = delete($args{key}) // '';
my $mutex = Myriad::Mutex->new(
%args,
key => $name,
key => $name . (length($suffix) ? "[$suffix]" : ''),
storage => $storage,
id => $service->uuid,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/Myriad/Transport/Redis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ async method del (@keys) {
}

async method set_unless_exists ($key, $v, $ttl) {
$log->infof('Set [%s] to %s with TTL %s', $key, $v, $ttl);
$log->tracef('Set [%s] to %s with TTL %s', $key, $v, $ttl);
await $redis->set(
$self->apply_prefix($key),
$v,
Expand Down
Loading