Skip to content

Commit

Permalink
Update remote executor example to reflect the executor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iNecas committed Feb 9, 2015
1 parent 9ae7cd8 commit bf5c8ac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Gemfile.lock
.bundle
.idea
.ruby-version
examples/remote_executor_db.sqlite
2 changes: 1 addition & 1 deletion examples/example_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def world

def create_world
config = Dynflow::Config.new
yield config if block_given?
config.persistence_adapter = persistence_adapter
config.logger_adapter = logger_adapter
yield config if block_given?
Dynflow::World.new(config)
end

Expand Down
50 changes: 29 additions & 21 deletions examples/remote_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,44 @@ class RemoteExecutorExample
class << self

def run_server
world = ExampleHelper.create_world(persistence_adapter: persistence_adapter)
listener = Dynflow::Listeners::Socket.new world, socket

Thread.new { Dynflow::Daemon.new(listener, world).run }
ExampleHelper.run_web_console(world)
ensure
File.delete(db_path)
world = ExampleHelper.create_world do |config|
config.persistence_adapter = persistence_adapter
config.connector = connector
end
begin
ExampleHelper.run_web_console(world)
rescue Errno::EADDRINUSE
STDIN.gets
end
end

def run_client
executor = ->(world) { Dynflow::Executors::RemoteViaSocket.new(world, socket) }
world = ExampleHelper.create_world(persistence_adapter: persistence_adapter,
executor: executor)

loop do
world.trigger(SampleAction).finished.wait
sleep 0.5
end
def db_path
File.expand_path("../remote_executor_db.sqlite", __FILE__)
end

def socket
File.join(Dir.tmpdir, 'dynflow_socket')
def persistence_conn_string
ENV['DB_CONN_STRING'] || "sqlite://#{db_path}"
end

def persistence_adapter
Dynflow::PersistenceAdapters::Sequel.new "sqlite://#{db_path}"
Dynflow::PersistenceAdapters::Sequel.new persistence_conn_string
end

def db_path
File.expand_path("../remote_executor_db.sqlite", __FILE__)
def connector
Proc.new { |world| Dynflow::Connectors::Database.new(world) }
end

def run_client
world = ExampleHelper.create_world do |config|
config.persistence_adapter = persistence_adapter
config.executor = false
config.connector = connector
end

loop do
world.trigger(SampleAction).finished.wait
sleep 0.5
end
end

end
Expand Down

0 comments on commit bf5c8ac

Please sign in to comment.