Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thbar/petite-lettre

YAML-based inter-process communication.
https://github.com/thbar/petite-lettre

Last synced: 2 months ago
JSON representation

YAML-based inter-process communication.

Awesome Lists containing this project

README

        

Petite-lettre is a little gem allowing YAML communication between a process and the child it launches.

h1. USAGE

The parent process launches its child and passes it a message using this kind of code:

PetiteLettre.call("ruby child_program.rb", { :command => :start_sale, :isbn => "1234567", :price => 12.4 })

The child process read the parent message using this kind of code:

PetiteLettre.receive do |message|

response = {}
if message[:command] == :start_sale
# do something here
raise "Price is too low" if message[:price] < 15.0
response[:status] = "OK"
response[:transaction_id] = "1235"
else
raise "Unknown command '#{message[:command]}'"
end
response
end

Petite-lettre uses $stdin and $stdout by default, although these can be customized with PetiteLettre.receive(input,output).

h1. MORE USAGE

Nothing stops you from writing a child process in another language (ie: C#, Java), as long as it knows how to read YAML from $stdin and output YAML on $stdout. Just the same - you can write a parent process in another language.

See petite_lettre.rb for implementation details.

h1. HISTORY

Petite-lettre is born out of the need to communicate between a MRI/Shoes front-end and a JRuby/Celerity back-end.

I'm pretty sure there is something already available out there to do that kind of things already. I just could not find them in a reasonable amount of time.

If it's the case, please mail me so I can bury petite-lettre for ever.

h1. CREDITS

I think I got that idea after using CouchDB for a while. I believe CouchDB uses JSON to communicate between its processes.

h1. IDEAS

* create a C# or Java client
* allow continuous communication (à la server)
* throw petite-lettre to the bin if I discover something that does the same thing at the same level of simplicity

h1. COPYRIGHT

Copyright (c) 2008 Thibaut Barrère. See LICENSE for details.