GithubHelp home page GithubHelp logo

train-station's Introduction

Train Station

Demo application based on Apache Pulsar

The purpose of this application is to show how to build a simple event-driven application on top of Apache Pulsar. This application is written in functional Scala with Tagless Final style and ZIO Task is used as the main effect. You can find detailed description of the app in the blog post - https://scala.monster/train-station/

Testing

In order to run unit tests:

sbt test

Running

This repository contains a docker-compose file, which includes 4 services:

  • Apache Pulsar
  • Zurich train station
  • Bern train station
  • Geneva train station

First, build a docker image of the service by running command:

sbt docker:publishLocal

When you have successfully built docker images you can start environment:

docker-compose up -d

This will start all the services in the background. All train stations will connect to Apache Pulsar. Services are starting much faster than Apache Pulsar so they will retry until it is ready.
A train station service is ready when you see a similar log message:

[2020-09-30T19:10:52.064Z] Started train station Bern

Calling service endpoints

To test if services are working correctly you can send a Departure request:

curl --request POST \
  --url http://localhost:8082/departure \
  --header 'content-type: application/json' \
  --data '{
	"id": "123",
	"to": "Bern",
	"time": "2020-12-03T10:15:30.00Z",
	"actual": "2020-12-03T10:15:30.00Z"
}'

This will create a departing train from Zurich to Bern. In order to mark train as arrived send another HTTP request:

curl --request POST \
  --url http://localhost:8081/arrival \
  --header 'content-type: application/json' \
  --data '{
	"trainId": "123",
	"time": "2020-12-03T10:15:30.00Z"
}'

train-station's People

Contributors

psisoyev avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.