
Event-Driven Architecture in Golang
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
All prices
More details
Other editions
Additional editions

Person
Michael E. Stack is currently working as a solutions architect in a consulting firm called Booz Allen Hamilton. Michael has been working with Golang for 7 years. I have been using Golang to write microservices and open-source tools. He has more than 20+ years of software development experience which involves 10 years of experience working with complex n-tier systems. He has created more than 50+ projects that are complex and involve messaging patterns.
Content
- Supporting Patterns In Brief
- Design and Planning
- Event Foundations
- Tracking Changes with Event Sourcing
- Asynchronous Connections
- Event-carried State Transfer
- Event Workflows
- Transactional Messaging
- Testing
- Deploying applications to the cloud
- Monitoring and Observability
Preface
Companies are adopting event-driven architecture (EDA) as their web applications grow in size and complexity. Applications that communicate using events are easier to develop and scale. Adding or developing your application around real-time interactions becomes easier with EDA.
Direct point-to-point communication between microservices inevitably leads to the development of a distributed monolith, which is just a monolith with extra and unnecessary complexity. EDA is an architecture that helps organizations to decouple microservices and avoid developing another distributed monolith.
Choosing a new architecture for your next application or deciding to refactor an existing one can be fraught with known and unknown challenges. It is my intention and this book's goal to provide you with enough examples and knowledge to give you a great head start should you decide to take the development of an EDA.
In this book, we will discuss and cover EDA concepts and related topics with the help of a small modular monolith demonstration application. We will use this application to take a journey through the concepts and topics to convert the synchronous mechanisms used by the application into asynchronous communication mechanisms.
Who this book is for
This architecture book is for developers working with microservices, or those architecting and designing new applications that will be built with microservices. Intermediate-level knowledge of Go is required to make the most of the examples and concepts in this book. Developers with a background in any programming language and experience working with microservices should still find the concepts and explanations useful.
What this book covers
Chapter 1, Introduction to Event-Driven Architectures, introduces EDA.
Chapter 2, Supporting Patterns in Brief, covers helpful patterns such as domain-driven design, domain-centric architectures, and application architectures.
Chapter 3, Design and Planning, explores the ways to discover the capabilities and features of an application using EventStorming and other methods.
Chapter 4, Event Foundations, introduces the Mallbots modular monolith application and domain events.
Chapter 5, Tracking Changes with Event Sourcing, introduces event sourcing and leads you through the development of event-sourced aggregates.
Chapter 6, Asynchronous Connections, covers adding asynchronous communication using event messages.
Chapter 7, Event-Carried State Transfer, expands on the use of message-based communication between components.
Chapter 8, Message Workflows, covers the concept of distributed transactions and introduces orchestrated sagas.
Chapter 9, Transactional Messaging, explores the use of message inboxes and outboxes to reduce data loss.
Chapter 10, Testing, discusses the concept of a testing strategy and leads you through testing an event-driven application.
Chapter 11, Deploying Applications to the Cloud, covers the use of infrastructure as code and deploying an application as microservices.
Chapter 12, Monitoring and Observability, discusses how to monitor a distributed application and make it observable with logging, metrics, and distributed tracing.
To get the most out of this book
This book is written with the expectation that you can execute the demonstration application to understand and view the code changes that have been made in each chapter as the application is refactored. To get the most out of the book, it is recommended you read the chapters in order, as the chapters will reference code that has been modified in the previous chapter.
Software/hardware covered in the book
Operating system requirements
Go 1.18+
Windows, macOS, or Linux
Docker 20.10.x
Windows, macOS, or Linux
NATS 2.4
Windows, macOS, or Linux
Most of the development for this book was done in Windows 10, but the code was tested to run in Windows Subsystem for Linux 2 (WSL 2) in Ubuntu 20.04 and tested to run on a Mac. You are expected to run the application and its dependencies within a Docker compose environment. Instructions to use Docker are given wherever possible to minimize installing new software on your machine.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can follow the author on GitHub (https://github.com/stackus) or make a connection with them on LinkedIn (https://www.linkedin.com/in/stackmichael).
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Event-Driven-Architecture-in-Golang. If there's an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/qgf1O.
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "If all the participants have responded positively, then the coordinator will send a COMMIT message to all of the participants and the distributed transaction will be complete."
A block of code is set as follows:
BEGIN; -- execute queries, updates, inserts, deletes . PREPARE TRANSACTION 'bfa1c57a-d99d-4d74-87a9-3aaabcc754ee';When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
func NewCommandHandlers( app application.App,) ddd.CommandHandler [ddd.Command] { return commandHandlers{ app: app,Any command-line input or output is written as follows:
--- PASS: TestApplication_AddItem (0.00s)
--- PASS: TestApplication_AddItem/NoBasket (0.00s)
--- PASS: TestApplication_AddItem/NoProduct (0.00s)
--- PASS: TestApplication_AddItem/NoStore (0.00s)
--- PASS: TestApplication_AddItem/SaveFailed (0.00s)
--- PASS: TestApplication_AddItem/Success (0.00s)
PASS
Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "The Customers module remains uncoupled from the Order Processing module because we do not have any explicit ties to the Order Processing module in this handler."
Tips or Important Notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: ePUB
Copy protection: without DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Use a reader that can handle the file format ePUB, such as Adobe Digital Editions or FBReader – both free (see eBook Help).
- Tablet/Smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePUB works well for novels and non-fiction books – i.e., 'flowing' text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook does not use copy protection or Digital Rights Management
For more information, see our eBook Help page.