GithubHelp home page GithubHelp logo

drruisseau / ticket-booking-aecor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vpavkin/ticket-booking-aecor

0.0 1.0 0.0 65 KB

Sample application for "Aecor — Purely functional event sourcing in Scala" series.

Home Page: https://pavkin.ru/aecor-intro/

License: Apache License 2.0

Scala 100.00%

ticket-booking-aecor's Introduction

Eventsourced ticket bookings with Aecor

This is a sample application for the "Aecor - Purely functional event sourcing in Scala" post series.

Prerequisites

Infrastructure for the app includes postgres and kafka, so you'll need either

  • docker-compose (recommended)
  • or have both postgres and kafka installed locally.

Running (with docker-compose)

  1. Launch infrastructure using compose (in the project folder):
docker-compose up -d
  1. If you are using docker-compose on macOS or Windows you should also forward all ports used in docker-compose.yml file (to be able to reach all Docker containers via localhost address). You can do this via docker-machine CLI or by a script such as docker-machine-port-forwarder:
pf 5432
pf 2181
pf 9092
  1. Run the app
sbt booking/run

Playing around

There are http endpoints you can call

Place booking:
curl --request POST \
  --url http://localhost:9000/clientA/bookings \
  --header 'content-type: application/json' \
  --data '{
	"concertId": "concertA",
	"seats": [
		{
			"row": 1,
			"number": 2
		},
		{
			"row": 1,
			"number": 3
		}
	]
}'
Get client bookings:
curl --request GET \
  --url http://localhost:9000/clientA/bookings
Emulate payment (via kafka message):

Payments are received from another service via PaymentReceived topic, so to emulate a payment we'll need to produce a message:

docker exec -it ticket-booking-aecor_kafka_1 /bin/bash

$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic PaymentReceived

{"clientId":"clientA", "paymentId":"12345", "bookingId": "<your_booking_id>"}

ticket-booking-aecor's People

Contributors

vpavkin avatar falconepl avatar

Watchers

 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.