Skip to content

Commit

Permalink
cleans up log calls in runners
Browse files Browse the repository at this point in the history
  • Loading branch information
robacarp committed Nov 2, 2024
1 parent 979276e commit 50041b2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/mosquito/runnable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ module Mosquito
"#{self.class.name.underscore.gsub("::", ".")}.#{self.object_id}"
}

private getter log : ::Log { Log.for runnable_name }

private def state=(state : State)
@state = state
end
Expand Down Expand Up @@ -156,7 +158,7 @@ module Mosquito
end
notifier.send state.finished?

Log.info { runnable_name + " has stopped" }
log.info { runnable_name + " has stopped" }
end

notifier
Expand Down
2 changes: 1 addition & 1 deletion src/mosquito/runners/coordinator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Mosquito::Runners
end

def runnable_name : String
"Coordinator<#{object_id}>"
"coordinator.#{object_id}"
end

def schedule : Nil
Expand Down
4 changes: 0 additions & 4 deletions src/mosquito/runners/executor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ module Mosquito::Runners
include RunAtMost
include Runnable

Log = ::Log.for self
getter log : ::Log

# How long a job config is persisted after success
property successful_job_ttl : Int32 { Mosquito.configuration.successful_job_ttl }

Expand All @@ -53,7 +50,6 @@ module Mosquito::Runners
end

def initialize(@job_pipeline, @idle_bell)
@log = Log.for(object_id.to_s)
end

# :nodoc:
Expand Down
3 changes: 1 addition & 2 deletions src/mosquito/runners/overseer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Mosquito::Runners
include RunAtMost
include Runnable

getter log : ::Log { Log.for(runnable_name) }
getter observer : Observability::Overseer { Observability::Overseer.new(self) }

getter queue_list : QueueList
Expand Down Expand Up @@ -61,7 +60,7 @@ module Mosquito::Runners
end

def runnable_name : String
"overseer.#{object_id}"
"overseer"
end

def sleep
Expand Down
8 changes: 3 additions & 5 deletions src/mosquito/runners/queue_list.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ require "./idle_wait"
module Mosquito::Runners
# QueueList handles searching the redis keyspace for named queues.
class QueueList
Log = ::Log.for self

include RunAtMost
include Runnable
include IdleWait
Expand All @@ -18,7 +16,7 @@ module Mosquito::Runners
end

def runnable_name : String
"QueueList<#{object_id}>"
"queue-list"
end

delegate each, to: @queues.shuffle
Expand All @@ -33,7 +31,7 @@ module Mosquito::Runners
candidate_queues = Mosquito.backend.list_queues.map { |name| Queue.new name }
new_queue_list = filter_queues candidate_queues

Log.notice {
log.notice {
queues_which_were_expected_but_not_found = @queues - new_queue_list
queues_which_have_never_been_seen = new_queue_list - @queues

Expand All @@ -55,7 +53,7 @@ module Mosquito::Runners
permitted_queues.includes? queue.name
end

Log.for("filter_queues").notice {
log.for("filter_queues").notice {
if filtered_queues.empty?
filtered_out_queues = present_queues - filtered_queues

Expand Down

0 comments on commit 50041b2

Please sign in to comment.