25
Jun 14

Joy of event sourcing


As a follow up to previous posts about event sourcing I strongly recommend to have a look at event sourcing sub chapter in The Joy of Clojure (affiliate link).

The book in general is a must read for Clojurists. It’s packed with many powerful ideas. I own paper copy of first edition and decided to buy second edition before it was even released.

Continue reading

23
Jun 14

Clojure Websockets server and event sourcing

In my previous post I explained what event sourcing is and why is it so interesting. Today I’m sharing a minimal multi-threaded implementation of websockets server that uses event sourcing. My language of choice is Clojure. I used core.async channels to enable communication between threads. Alternatively, you may use blocking queues and manually create threads – it may be more performant but I haven’t tested it. Another alternative is to use Disruptor for inter-thread communication – it is probably the most performant method but I also haven’t checked it yet.

Continue reading

18
Jun 14

Make business logic simple using event sourcing and a lot of RAM

Recently I’ve been playing with asynchronous HTTP processing and event sourcing. The aim was to create a fast and elegant solution for multiplayer game engine.

Asynchronous servers make it possible to handle a lot of client connections concurrently. It is achieved by handling more than one connection on one thread as opposed to thread per connection approach. The most famous example of such server is Node.js with its single thread processing. Exactly the same style of dealing with connections is possible in Java and Clojure with additional power of using extra threads for other tasks (i.e. other than HTTP I/O). For implementation, I used http-kit that is not using Netty (that’s refreshing!) as an underlying library.

Event sourcing is a nice model for asynchronous processing. It allows to separate the business logic from I/O and makes it easy to put logic in its own thread. As pointed out by guys from LMAX, it also means that mutable domain data structures are less harmful or even acceptable. This is not the case in other threaded application architectures that involve sharing data between threads.

Continue reading

29
Nov 13

Spring exchange 2013

Two weeks ago I attended a Spring conference in London. It was held in a crypt under a church, which shows how creative Skillsmatter can be – even when it comes to looking for a venue

This post is an overview of what is currently happening in Spring ecosystem. Many conference talks concerned a new version of Spring that is going to be released in December. Fourth edition of framework is meant to be an evolutionary one and version bump in your config is strongly recommended by creators, who promise a smooth migration. Additionally, Spring 4 supports JDK 8, it’s developer preview was released in September (you can now grab free IntelliJ IDE and try out them lambdas! Not yet supported in Eclipse though).

Continue reading

31
Aug 13

Auto index in JSON

I’m in the process of setting up my personal dedicated server. One of the standard features of web servers is creating automatic responses for directory content listing. There is mod_autoindex for Apache, and autoindex for Nginx. Both are able to produce nice and simply looking web pages that allow to navigate a directory structure on the server. What they cannot produce is a response that is actually useful for consumption by client software – a JSON response. Because of that they are not suitable for Javascript parsing.

Continue reading

18
Aug 13

Toy project: Cathedral

I have neglected my blog during the last few months but that’s just because I was very busy. In the meantime, among other things, I flew 20 times on route Gdansk – London, relocated to Reading (UK), and… started a new toy project :)

Project is called Cathedral and it is an implementation of a board game called Basilica. The core game logic is written in ClojureScript. The web application part uses Angular.js, and wherever possible, CSS for the user interface. I’m thinking about using LESS or generating styles in Clojure as style rules are getting pretty repetetive. It is still work in progress.

Continue reading

24
Jan 13

Frontend centric free hosting at Github

While struggling to find a decent hosting for toy projects I stumbled upon a completely free solution – Github Pages. It is feasible to think of Github as a free and scalable hosting platform for… ClojureScript powered web apps (or any other JavaScript centric one)! As stated by company employee, Github Pages service has no traffic limits (however some files used by XXX sites were banned due to JavaScript hotlinking).

One of the least known features offered by Github is hosting of static html pages with support of Jekyll static content generator. Well, at least I’ve found out about it very recently. Pages can be attached to the user domain (username.github.com) or to each of the user’s repositories (username.github.com/repository). A custom domain may also be used.

Continue reading