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.6.0.pre.2 lib/steep/drivers/worker.rb
steep-1.6.0.pre.1 lib/steep/drivers/worker.rb
steep-1.5.3 lib/steep/drivers/worker.rb
steep-1.5.2 lib/steep/drivers/worker.rb
steep-1.5.1 lib/steep/drivers/worker.rb
steep-1.5.0 lib/steep/drivers/worker.rb
steep-1.5.0.pre.6 lib/steep/drivers/worker.rb
steep-1.5.0.pre.5 lib/steep/drivers/worker.rb
steep-1.5.0.pre.4 lib/steep/drivers/worker.rb
steep-1.5.0.pre.3 lib/steep/drivers/worker.rb
steep-1.5.0.pre.2 lib/steep/drivers/worker.rb
steep-1.5.0.pre.1 lib/steep/drivers/worker.rb
steep-1.4.0 lib/steep/drivers/worker.rb
steep-1.4.0.dev.5 lib/steep/drivers/worker.rb
steep-1.4.0.dev.4 lib/steep/drivers/worker.rb
steep-1.4.0.dev.3 lib/steep/drivers/worker.rb
steep-1.3.2 lib/steep/drivers/worker.rb
steep-1.3.1 lib/steep/drivers/worker.rb
steep-1.4.0.dev.2 lib/steep/drivers/worker.rb
steep-1.4.0.dev.1 lib/steep/drivers/worker.rb