/README.md

http://github.com/biilmann/eventsource-broker · Markdown · 88 lines · 64 code · 24 blank · 0 comment · 0 complexity · 201100e17e3dd3e8ed3cf54fe4d32403 MD5 · raw file

  1. EvenSource Broker
  2. =================
  3. A simple bridge between EventSource and an AMQP fanout exchange.
  4. EventSource is a new browser standard released as part of the HTML5
  5. spec.
  6. It lets the browser send a never-ending HTTP request to a server and
  7. provides a javascript API for binding to events pushed from the server.
  8. EventSource is very handy when you don't need the full bidirectional
  9. communication that Websockets offers. it plays well with load-balancers,
  10. intermediary proxies and HTTPS termination.
  11. This library sets up an EventSource that clients can connect to
  12. specifying a channel to listen to in the query string. The server
  13. connects to a fanout AMQP exchange and routes AMQP messages as events to
  14. the javascript clients.
  15. MongoDB is used to store user and connection information.
  16. The server expects the AMQP messages to be JSON following the format:
  17. {
  18. "channel": "some-channel", // Required
  19. "data": "{/"msg/": /"data/"}", // Required
  20. "id": "event-id", // optional
  21. "name": "event-name" // optional
  22. }
  23. To open connections to a channel a user with an key and a secret is
  24. expected to exist in the database. Before opening a connection a socket
  25. id must be aquired from by calling POST /socket
  26. A simple example of how to interact with this API can be found in the
  27. [https://github.com/eshq/eshq-gem](eshq ruby gem).
  28. Installation
  29. ============
  30. Clone the repository, cd to the root of it and execute
  31. cabal install
  32. Run as:
  33. eventsource-broker -p <port>
  34. The broker will look for an AMQP_URL environment variable for a broker
  35. to connect to. It also takes a MONGO_URL for configuring the database
  36. connection and an ORIGIN variable that should be a url the server runs
  37. on for cross domain requests.
  38. License
  39. =======
  40. Copyright (c)2011, Mathias Biilmann <info@mathias-biilmann.net>
  41. All rights reserved.
  42. Redistribution and use in source and binary forms, with or without
  43. modification, are permitted provided that the following conditions are met:
  44. * Redistributions of source code must retain the above copyright
  45. notice, this list of conditions and the following disclaimer.
  46. * Redistributions in binary form must reproduce the above
  47. copyright notice, this list of conditions and the following
  48. disclaimer in the documentation and/or other materials provided
  49. with the distribution.
  50. * Neither the name of Mathias Biilman <info@mathias-biilmann.net>
  51. nor the names of other contributors may be used to endorse or
  52. promote products derived from this software without specific prior
  53. written permission.
  54. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  55. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  56. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  57. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  58. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  59. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  60. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  61. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  62. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  63. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  64. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE