Skip to content
Agents in an EventMachine Box
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.document
.gitignore
.rspec
.rvmrc
.travis.yml
Gemfile
Gemfile.lock
Guardfile
LICENSE.txt
README.markdown
Rakefile
VERSION
em-box.gemspec

README.markdown

README

Build Status

Code Climate

Basics

server.rb (forks a subprocess):

EM.popen("ruby [...] -e 'MyClient.new'", ClientConnection)

agent.rb (in order to receive input the stdin will be attached to EM)

EM::attach($stdin, ServerConnection)

Messages

JSON is used for messages

{
  status: 'ready'
}

{
  message: 'action',
  arguments: [arg1,arg2]
}

{
  receiver: <uuid_for_population>
  message: 'action',
  arguments: [arg1,arg2]
}

a message that expects a return value

{
  message: 'action',
  arguments: [arg1,arg2],
  return: uuid
}

{
  return: uuid,
  value: 'return value'
}

Credits

Thanks to

  • Avdi Grimm for his series 'A dozen (or so) ways to start sub-processes in Ruby' part 1, part 2 and part 3
  • Tass Cyberspace for inspiring me back

Copyright

Copyright (c) 2012 Alessandro Di Maria. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.