Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

shortishly/lighthouse

Repository files navigation

Lighthouse

Lighthouse is a small, fast, modular event push server written in Erlang.

The server presents a hierarchy of event source topics wrapped in the ATOM syndication format. This hierarchy may be used to model chat rooms, lobbies, etc, which can be navigated by a client to reach a suitable event source.

Building

Lighthouse uses erlang.mk. To build run:

make

Build Status

Quick Start

Bring up an instance of elasticsearch and also kibana, which lighthouse uses for reporting.

docker-compose up

Leave the above running and start a new terminal with:

./start-dev.sh

By default lighthouse logs some usage statstics to the elasticsearch instance started above every 30 seconds:

open http://$(boot2docker ip):5601/

If you are not using boot2docker replace the above with the IP address of your docker host.

Tell kibana about the indexes that elastic has created by navigating to "Settings" use the default index name or pattern as "logstash-*" and select "timestamp" as the time-field name. If at first nothing appears, wait 30 seconds or so, and click "refresh fields".

Pushing some example data

In this example, we will imagine a collection of temperature sensors that are in located in a house. To push an event to the server, we need 3 things: the topic, some data and an event. In this example we will use the topic of floors/ground/rooms/kitchen, an event of temperature, and data of 21:

curl --include --data data=22 --data event=temperature --data topic=floors/ground/rooms/kitchen http://127.0.0.1:8181/events

In another terminal connect to the stream for the kitchen topic:

curl -i http://127.0.0.1:8181/topic/floors/ground/rooms/kitchen

Push some further temperature changes:

curl --include --data data=23 --data event=temperature --data topic=floors/ground/rooms/kitchen http://127.0.0.1:8181/events
curl --include --data data=24 --data event=temperature --data topic=floors/ground/rooms/kitchen http://127.0.0.1:8181/events

Observe the events that are emitted on the kitchen topic.

You can use your browser to look at the topic structure that has been created, using the following URL:

curl -s http://127.0.0.1:8181/topics|xmllint --format -

This URL presents the topic hierarchy using the ATOM syndication format. You can follow the structure in your browser, and also navigate and view an event stream.