Functional event-driven architecture: Powered by Scala 3
$24.99
Minimum price
$49.99
Suggested price

Functional event-driven architecture: Powered by Scala 3

About the Book

Explore the event-driven architecture (EDA) in a purely functional way, mainly powered by Fs2 streams in Scala 3.

In the same spirit of Practical FP in Scala, we will develop a distributed system that meets the requirements of a modern software architecture capable of processing billions of events per day at scale using Apache Pulsar.

It also includes a Web Sockets service powered by Http4s, and a Web application written in ELM.

Although the application picks a particular design and implementation, the concepts should easily translate to other designs in the same space that can be built on top of Apache Kafka, Rabbit MQ, or other message brokers.

  • Share this book

  • Feedback

About the Author

Gabriel Volpe
Gabriel Volpe

Gabriel Volpe is a Software Engineer, specialized in functional programming, from Buenos Aires, Argentina. He has been writing code since 2005, and nowadays writes Haskell & Scala, while keeping reproducible builds via Nix.

Table of Contents

  • Preface
  • Acknowledgments
    • People
    • Software
    • Fonts
  • Prerequisites
  • How to read this book
    • Conventions used in this book
  • 1. Chapter 1: Event-driven architecture
    • 1.1 Introduction
      • 1.1.1 What problems does it solve?
      • 1.1.2 When should you use it? When not?
    • 1.2 Microservices architecture
    • 1.3 CQRS & event sourcing
    • 1.4 Summary
  • 2. Chapter 2: Distributed systems
    • 2.1 Challenges
      • 2.1.1 Identifying points of failure
      • 2.1.2 Consistency & availability: CAP theorem
    • 2.2 Idempotent services
      • 2.2.1 De-duplication
    • 2.3 Atomic transactions
      • 2.3.1 Distributed locks
    • 2.4 Summary
  • 3. Chapter 3: Stateless vs Stateful
    • 3.1 Stateless services, stateful brokers
      • 3.1.1 Stateful services
      • 3.1.2 Application clustering
    • 3.2 Message-driven architecture
      • 3.2.1 Delivery guarantees
      • 3.2.2 Apache Kafka
      • 3.2.3 Apache Pulsar
    • 3.3 State snapshots
      • 3.3.1 Retention policy
    • 3.4 Schema evolution
      • 3.4.1 Central schema registry
      • 3.4.2 Backward compatibility
      • 3.4.3 Protocols
    • 3.5 Summary
  • 4. Chapter 4: Functional programming in Scala 3
    • 4.1 Domain modeling
      • 4.1.1 Typeclass derivation
      • 4.1.2 Newtypes
      • 4.1.3 Refinement types
      • 4.1.3 Orphan instances
    • 4.2 Typeclasses
    • 4.3 HTTP routes
    • 4.4 Effectful context
    • 4.5 Summary
  • 5. Chapter 5: Effectful streams
    • 5.1 Finite state machines
    • 5.2 Lifecycle, resource management
    • 5.3 Data pipeline
      • 5.3.1 Parsing CSV files
      • 5.3.2 Batching
    • 5.4 Producer-consumer
      • 5.4.1 In-memory via Topic & Queue
      • 5.4.1 Distributed via Apache Pulsar
    • 5.5 Summary
  • 6. Chapter 6: Trading project
    • 6.1 Business requirements
      • 6.1.1 Domain modeling
      • 6.2.1 Shared modules
    • 6.2 Stateless services
      • 6.2.1 Processor
      • 6.2.2 Alerts
      • 6.2.3 Snapshots
      • 6.2.4 Websockets server
      • 6.2.5 Feed
    • 6.3 Bottlenecks
      • 6.3.1 Error handling
    • 6.4 Testing services
      • 6.4.1 Unit tests
      • 6.4.2 Integration tests
    • 6.5 Monitoring
      • 6.5.1 Prometheus
      • 6.5.2 Grafana
    • 6.6 Deployment
      • 6.6.1 K8s cluster
      • 6.6.2 Roll-out restarts
    • 6.7 Summary

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$10,894,929writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub