Ruby 使用 DRb 启动远程对象服务

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require "drb"
require "drb_observer"

class Ticker 
  include DRbObservable

  def initialize()
    Thread.new { run }
  end

  def run
    loop do
      price = 10
      print "Current price: #{price}\n"
      notify_observers(Time.now, price)
      sleep 1
    end
  end
end

ticker = Ticker.new()

DRb.start_service('druby://localhost:9001', ticker)
puts 'Press [return] to exit.'
gets