Skip to content

jherrlin/bomberman-with-clara

Repository files navigation

Claraman

Claraman is a multiplayer game project around two concepts. A rule engine named Clara and event sourcing.

The running game can be found at https://bomberman.lambda-group.se/

Clara

Clara is a rule engine written in Clojure/Script.

Resources:

Event sourcing

Events in the system tries to follow the CloudEvent specification. Take a look at Johan Halebys Occurent for nice documentation on event sourcing.

In this bomberman game all events are saved into a list, the list is called the event store. Each time the list updates the changes are sent through a reduce function together with the old game state. The reduce function updates the game state by taking the old game state and the new events and returns a new game state. In CQRS terms the game state would be called a read model. It’s a derived state used by the game to represent the current state of the game. The game is always reading from the game state and never does writes to it. To update the game state the app creates new events that are appended to the list in the event store.

+------------------+
| List with events |
+-------+----------+
        |
        |
        ↓
+-------+---------+        ------------
| Reduce function +------>( Game state )
+-----------------+        ------------

Other libraries in use

here is a handful of the libraries used in this project and what they do.

  • component for orchestrating stateful server side components
  • sente for websocket communication
  • re-frame for single pages client application

Production server setup and CD

Server setup is done with Ansible. Look in the ansible folder for details. Continuous delivery is made with help from CircleCi. CirclCi tests the code and builds an artifact. CirclCi then ships the artifact to the server via SSH. When the server gets the new artifact Systemd picks up the changes and restarts the application with the new artifact.

Update deps

Instructions on how to update dependencies.

clojure -Moutdated --write

Development with Emacs

With Vlaaads Reveal

  1. Starta a repl from command line =clojure -A:reveal:test:dev -m nrepl.cmdline –middleware ‘[vlaaad.reveal.nrepl/middleware]’=
  2. Connect to the repl from Emacs with cider-connect-clj
  3. Start a ClojureScript repl with cider-jack-in-cljs

Without Reveal

  1. Start Clj and Cljs repls with cider-jack-in-clj&cljs