Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
zachahn committed May 24, 2024
1 parent 92f7ca4 commit 8098820
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/disqualified/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def option_parser
server_options.pool_size = value
end

opts.on("--queue QUEUE", String, "Default: All queues. Repeat for multiple queues and priority") do |value|
server_options.specify_queue(value)
end

opts.on("-h", "--help", "Prints this help") do
puts opts
exit
Expand Down
20 changes: 19 additions & 1 deletion lib/disqualified/server_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def initialize
@pool_size = T.let(5, Integer)
@pwd = T.let(Dir.pwd, String)
@error_hooks = T.let([], T::Array[Disqualified::Logging::ERROR_HOOK_TYPE])
@queues = T.let([], T::Array[Symbol])
end

sig { returns(Numeric) }
Expand All @@ -43,8 +44,11 @@ def initialize
attr_accessor :pool_size
sig { returns(String) }
attr_accessor :pwd
sig { returns(T::Array[Symbol]) }
attr_accessor :queues

private :error_hooks=
private :queues=

sig { returns(T::Range[Float]) }
def delay_range
Expand All @@ -56,8 +60,22 @@ def on_error(&block)
error_hooks.push(block)
end

sig { params(queue: T.any(String, Symbol)).void }
def specify_queue(queue)
queues.push(queue.to_sym)
end

sig { returns(String) }
def queues_to_s
if queues.empty?
"ALL_QUEUES"
else
"[#{queues.join(", ")}]"
end
end

sig { returns(String) }
def to_s
"{ delay: #{delay_range}, pool_size: #{pool_size}, error_hooks_size: #{error_hooks.size} }"
"{ delay: #{delay_range}, pool_size: #{pool_size}, error_hooks_size: #{error_hooks.size}, queues: #{queues_to_s} }"
end
end

0 comments on commit 8098820

Please sign in to comment.