Skip to content

Commit

Permalink
Merge pull request #137 from soutaro/master-worker
Browse files Browse the repository at this point in the history
Spawn workers for performance
  • Loading branch information
soutaro committed May 17, 2020
2 parents c9c6d6e + c94cd08 commit 1fef843
Show file tree
Hide file tree
Showing 31 changed files with 2,668 additions and 865 deletions.
11 changes: 11 additions & 0 deletions lib/steep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
require "listen"
require 'pry'
require 'language_server-protocol'
require "etc"
require "open3"

require "rbs"

Expand Down Expand Up @@ -70,6 +72,14 @@
require "steep/type_inference/logic"
require "steep/ast/types"

require "steep/server/utils"
require "steep/server/base_worker"
require "steep/server/code_worker"
require "steep/server/signature_worker"
require "steep/server/worker_process"
require "steep/server/interaction_worker"
require "steep/server/master"

require "steep/project"
require "steep/project/file"
require "steep/project/options"
Expand All @@ -89,6 +99,7 @@
require "steep/drivers/print_project"
require "steep/drivers/init"
require "steep/drivers/vendor"
require "steep/drivers/worker"

if ENV["NO_COLOR"]
Rainbow.enabled = false
Expand Down
17 changes: 16 additions & 1 deletion lib/steep/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def process_global_options

def setup_command
@command = argv.shift&.to_sym
if CLI.available_commands.include?(@command)
if CLI.available_commands.include?(@command) || @command == :worker
true
else
stderr.puts "Unknown command: #{command}"
Expand Down Expand Up @@ -159,5 +159,20 @@ def process_version
stdout.puts Steep::VERSION
0
end

def process_worker
Drivers::Worker.new(stdout: stdout, stderr: stderr, stdin: stdin).tap do |command|
OptionParser.new do |opts|
opts.banner = "Usage: steep worker [options] [dir]"
handle_logging_options opts

opts.on("--interaction") { command.worker_type = :interaction }
opts.on("--code") { command.worker_type = :code }
opts.on("--signature") { command.worker_type = :signature }
opts.on("--steepfile=PATH") {|path| command.steepfile = Pathname(path) }
opts.on("--name=NAME") {|name| command.worker_name = name }
end.parse!(argv)
end.run
end
end
end
2 changes: 1 addition & 1 deletion lib/steep/drivers/annotations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run

project.targets.each do |target|
Steep.logger.tagged "target=#{target.name}" do
target.load_signatures do |_, subtyping, _|
target.load_signatures(validate: false) do |_, subtyping, _|
case (status = target.status)
when nil # status set on error cases
target.source_files.each_value do |file|
Expand Down
Loading

0 comments on commit 1fef843

Please sign in to comment.