Sha256: f73db23245082c69736eb8f1cfaa311173fe976e38313adf655ea425476fe2f5

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 KB

Contents

module Steep
  module Server
    class BaseWorker
      LSP = LanguageServer::Protocol

      include Utils

      attr_reader :project
      attr_reader :reader, :writer

      def initialize(project:, reader:, writer:)
        @project = project
        @reader = reader
        @writer = writer
      end

      def handle_request(request)
        # process request
      end

      def handle_job(job)
        # process async job
      end

      def run
        tags = Steep.logger.formatter.current_tags.dup
        thread = Thread.new do
          Steep.logger.formatter.push_tags(*tags)
          Steep.logger.tagged "background" do
            while job = queue.pop
              handle_job(job)
            end
          end
        end

        Steep.logger.tagged "frontend" do
          begin
            reader.read do |request|
              case request[:method]
              when "shutdown"
                # nop
              when "exit"
                break
              else
                handle_request(request)
              end
            end
          ensure
            queue << nil
            thread.join
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
steep-0.25.0 lib/steep/server/base_worker.rb
steep-0.24.0 lib/steep/server/base_worker.rb
steep-0.23.0 lib/steep/server/base_worker.rb
steep-0.22.0 lib/steep/server/base_worker.rb
steep-0.21.0 lib/steep/server/base_worker.rb
steep-0.20.0 lib/steep/server/base_worker.rb
steep-0.19.0 lib/steep/server/base_worker.rb
steep-0.18.0 lib/steep/server/base_worker.rb
steep-0.17.1 lib/steep/server/base_worker.rb
steep-0.17.0 lib/steep/server/base_worker.rb
steep-0.16.3 lib/steep/server/base_worker.rb
steep-0.16.2 lib/steep/server/base_worker.rb
steep-0.16.1 lib/steep/server/base_worker.rb
steep-0.16.0 lib/steep/server/base_worker.rb