-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
add ability to configure global Redis namespace prefix #134
Merged
robacarp
merged 9 commits into
mosquito-cr:master
from
NeuraLegion:feat/global-redis-ns-prefix
May 14, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d4b914f
add ability to configure global Redis namespace prefix
dammer e99c258
fix: return back original .tool-version
dammer cbc31c6
spec: add configuration global_prefix
dammer a331243
spec: add prefix test on build key
dammer db0b69f
ref: simplify
dammer 9cc9015
fix: ameba performance
dammer 3fb51ff
fix: ameba negated conds
dammer c0aa741
fix: ameba style
dammer e315789
fix: early init metadata in PeriodicJobRun
dammer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ module Mosquito | |
end | ||
|
||
def self.delete(key : String, in ttl : Int64 = 0) : Nil | ||
if (ttl > 0) | ||
if ttl > 0 | ||
redis.expire key, ttl | ||
else | ||
redis.del key | ||
|
@@ -124,14 +124,14 @@ module Mosquito | |
key = build_key(LIST_OF_QUEUES_KEY) | ||
list_queues = redis.zrange(key, 0, -1).as(Array) | ||
|
||
return [] of String unless list_queues.any? | ||
return [] of String if list_queues.empty? | ||
|
||
list_queues.compact_map(&.as(String)) | ||
end | ||
|
||
def self.list_runners : Array(String) | ||
runner_prefix = "mosquito:runners:" | ||
Redis.instance.keys("#{runner_prefix}*") | ||
runner_prefix = build_key(LIST_OF_QUEUES_KEY) | ||
Redis.instance.keys("#{runner_prefix}:*") | ||
.map(&.as(String)) | ||
.map(&.sub(runner_prefix, "")) | ||
end | ||
|
@@ -159,7 +159,7 @@ module Mosquito | |
time = Time.utc | ||
overdue_job_runs = redis.zrangebyscore(scheduled_q, "0", time.to_unix_ms.to_s).as(Array) | ||
|
||
return [] of JobRun unless overdue_job_runs.any? | ||
return [] of JobRun if overdue_job_runs.empty? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, I'd ask for ameba fixes to be submitted separately, just so the changes history doesn't get too muddled. In this case, 👍 and thank you. |
||
|
||
overdue_job_runs.compact_map do |job_run_id| | ||
redis.zrem scheduled_q, job_run_id.to_s | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement. The use of #keys here is still a performance implication and can abuse redis servers regardless of the search string, but that's an unrelated issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's possible to use build_key once here, and then cache the value in the getter
runner_prefix
to improve performance, but I'm not sure.