Sha256: 699a9052a7516d4baf15d72e2708dbbecf3fc1b63be6dbfba3e7be7ccc8bf8ea

Contents?: true

Size: 1.81 KB

Versions: 43

Compression:

Stored size: 1.81 KB

Contents

module Steep
  module Drivers
    class Worker
      attr_reader :stdout, :stderr, :stdin

      attr_accessor :worker_type
      attr_accessor :worker_name
      attr_accessor :delay_shutdown
      attr_accessor :max_index
      attr_accessor :index
      attr_accessor :commandline_args

      include Utils::DriverHelper

      def initialize(stdout:, stderr:, stdin:)
        @stdout = stdout
        @stderr = stderr
        @stdin = stdin
        @commandline_args = []
      end

      def run()
        Steep.logger.tagged("#{worker_type}:#{worker_name}") do
          project = load_config()

          reader = LanguageServer::Protocol::Transport::Io::Reader.new(stdin)
          writer = LanguageServer::Protocol::Transport::Io::Writer.new(stdout)

          worker = case worker_type
                   when :typecheck
                     assignment = Services::PathAssignment.new(max_index: max_index, index: index)
                     Server::TypeCheckWorker.new(project: project,
                                                 reader: reader,
                                                 writer: writer,
                                                 assignment: assignment,
                                                 commandline_args: commandline_args)
                   when :interaction
                     Server::InteractionWorker.new(project: project, reader: reader, writer: writer)
                   else
                     raise "Unknown worker type: #{worker_type}"
                   end

          unless delay_shutdown
            worker.skip_jobs_after_shutdown!
          end

          Steep.logger.info "Starting #{worker_type} worker..."

          worker.run()
        rescue Interrupt
          Steep.logger.info "Shutting down by interrupt..."
        end

        0
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
steep-1.9.1 lib/steep/drivers/worker.rb
steep-1.9.0 lib/steep/drivers/worker.rb
steep-1.9.0.dev.2 lib/steep/drivers/worker.rb
steep-1.9.0.dev.1 lib/steep/drivers/worker.rb
steep-1.8.3 lib/steep/drivers/worker.rb
steep-1.8.2 lib/steep/drivers/worker.rb
steep-1.8.1 lib/steep/drivers/worker.rb
steep-1.8.0 lib/steep/drivers/worker.rb
steep-1.8.0.pre.2 lib/steep/drivers/worker.rb
steep-1.8.0.pre.1 lib/steep/drivers/worker.rb
steep-1.8.0.dev.2 lib/steep/drivers/worker.rb
steep-1.8.0.dev.1 lib/steep/drivers/worker.rb
steep-1.7.1 lib/steep/drivers/worker.rb
steep-1.7.0 lib/steep/drivers/worker.rb
steep-1.7.0.dev.3 lib/steep/drivers/worker.rb
steep-1.7.0.dev.2 lib/steep/drivers/worker.rb
steep-1.7.0.dev.1 lib/steep/drivers/worker.rb
steep-1.6.0 lib/steep/drivers/worker.rb
steep-1.6.0.pre.4 lib/steep/drivers/worker.rb
steep-1.6.0.pre.3 lib/steep/drivers/worker.rb