Sha256: 0f0ba3bee6ac494f38c42eceef6e1d0025a90518f5cd879ad4b2f1892c06eeb6

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

module GemeraldBeanstalk::Plugin::DirectConnection
  class Client

    attr_reader :beanstalk, :connection

    def close_connection
      return unless connection.alive?
      connection.close_connection
      beanstalk.disconnect(self)
    end


    def initialize(beanstalk)
      @beanstalk = beanstalk
      @connection = beanstalk.connect(self)
      @async_response = nil
    end


    def transmit(message)
      message += "\r\n" unless message[-2, 2] == "\r\n"
      connection.execute(message)
      while (async_response = @async_response).nil?
        sleep 0.1
      end
      @async_response = nil
      return async_response
    end


    def send_data(message)
      @async_response = message
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemerald_beanstalk-0.1.0 lib/gemerald_beanstalk/plugins/direct_connection/client.rb