Sha256: d424de6e3b1e38a0000db067886b38b254acfabbaefe870b23da2b631395d012
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
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.
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
thbar-petite-lettre-1.0.0 | README.textile |
petite-lettre-1.0.0 | README.textile |