Skip to content

Instantly share code, notes, and snippets.

@halorgium
Forked from reset/gist:5131168
Last active December 14, 2015 18:39
Show Gist options
  • Save halorgium/5131182 to your computer and use it in GitHub Desktop.
Save halorgium/5131182 to your computer and use it in GitHub Desktop.
require 'celluloid'
class Something
class RemoteScriptError < RuntimeError; end
include Celluloid
def ssh_command(*)
[false, Struct.new(:stdout, :stderr).new("out", "err")]
end
def ruby_script(name, host, options = {})
name = name.split('.rb')[0]
script = "script" # File.read(MB.scripts.join("#{name}.rb"))
command = "command" # #{EMBEDDED_RUBY_PATH} -e '#{script}'"
status, response = ssh_command(host, command, options)
case status
when :ok
response.stdout.chomp
when :error
abort RemoteScriptError.new(response.stderr.chomp)
end
end
def node_name(host, options = {})
ruby_script('node_name', host, options)
rescue RemoteScriptError
nil
end
end
class Worker
include Celluloid
def initialize
@something = Something.new
end
def nodes
f = @something.future(:node_name, "hello.local")
f.value # expect nil but get RemoteScriptError
end
end
p Worker.new.nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment