Book Image

Clojure Data Structures and Algorithms Cookbook

By : Rafik Naccache
Book Image

Clojure Data Structures and Algorithms Cookbook

By: Rafik Naccache

Overview of this book

Table of Contents (14 chapters)
Clojure Data Structures and Algorithms Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Designing an online taxi-booking engine


Asynchronous programming is a very good choice for making independent processes collaborate, relieving the designer from the burden of maintaining a global state for all of the entities at stake. We are going to showcase this in a recipe, in which we will simulate an online taxi-booking engine.

In the system we are longing to build, no global state will be maintained. Instead, we are going to fire as many processes as we have taxis, and a couple more to ensure that the collaboration between them occurs properly. Finally, customer requests will land in our system from the outer world via channels.

The rules our taxi-booking engine obeys will be kept as simple as possible a given taxi, whose status is initially :free, keeps moving randomly around town unless it receives from headquarters a customer request that matches the place it happens to be in at that particular moment. Then, it notifies headquarters that it is willing to process that particular request...