Skip to content

Commit

Permalink
Adjust deploy API so you can easily pass in custom pool, #5647
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Nov 30, 2022
1 parent 78deaa5 commit aac4237
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/sidekiq/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class Deploy
}

def self.mark!(label = nil)
label ||= LABEL_MAKER.call
Sidekiq::Deploy.new.mark(label: label)
Sidekiq::Deploy.new.mark!(label: label)
end

def initialize(pool = Sidekiq::RedisConnection.create)
@pool = pool
end

def mark(at: Time.now, label: "")
def mark!(at: Time.now, label: nil)
label ||= LABEL_MAKER.call
# we need to round the timestamp so that we gracefully
# handle an very common error in marking deploys:
# having every process mark its deploy, leading
Expand Down
7 changes: 4 additions & 3 deletions test/metrics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def create_known_metrics(time = fixed_time)
floor = whence.utc.rfc3339.sub(":15", ":00")

d = Sidekiq::Deploy.new
d.mark(at: whence, label: "cafed00d - some git summary line")
d.mark!(at: whence, label: "cafed00d - some git summary line")
d.mark!(at: whence)

q = Sidekiq::Metrics::Query.new(now: whence)
rs = q.for_job("FooJob")
Expand Down Expand Up @@ -104,7 +105,7 @@ def create_known_metrics(time = fixed_time)
it "fetches top job data" do
create_known_metrics
d = Sidekiq::Deploy.new
d.mark(at: fixed_time - 300, label: "cafed00d - some git summary line")
d.mark!(at: fixed_time - 300, label: "cafed00d - some git summary line")

q = Sidekiq::Metrics::Query.new(now: fixed_time)
result = q.top_jobs
Expand Down Expand Up @@ -133,7 +134,7 @@ def create_known_metrics(time = fixed_time)
it "fetches job-specific data" do
create_known_metrics
d = Sidekiq::Deploy.new
d.mark(at: fixed_time - 300, label: "cafed00d - some git summary line")
d.mark!(at: fixed_time - 300, label: "cafed00d - some git summary line")

q = Sidekiq::Metrics::Query.new(now: fixed_time)
result = q.for_job("App::FooJob")
Expand Down

0 comments on commit aac4237

Please sign in to comment.