Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/thbar/petite-lettre
- Owner: thbar
- License: mit
- Created: 2009-03-02T10:08:58.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2010-09-07T08:19:51.000Z (over 14 years ago)
- Last Synced: 2024-09-17T03:10:26.940Z (3 months ago)
- Language: Ruby
- Size: 85.9 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: LICENSE
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
endPetite-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 simplicityh1. COPYRIGHT
Copyright (c) 2008 Thibaut Barrère. See LICENSE for details.