avatarHannah Callisto

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3937

Abstract

represent the state changes of the bank account. Each event contains a timestamp, the type of event (deposit, withdrawal, interest accrual), and the amount of the change. To reconstruct the current state of the account, the event stream is replayed, and the cumulative effect of the events is calculated.</p><p id="5b20"><b>Example Events </b>Here are some examples of events that might occur in a bank account:</p><ul><li><b>DepositMadeEvent(accountID, amount, timestamp)</b></li><li><b>WithdrawalMadeEvent(accountID, amount, timestamp)</b></li><li><b>InterestAccruedEvent(accountID, amount, timestamp)</b></li></ul><p id="846d"><b>Reconstructing the Current State </b>To reconstruct the current balance of an account, the event stream is replayed from the beginning. For each event, the corresponding amount is added or subtracted from the current balance. For example, if the event stream contains the following events:</p><div id="64a6"><pre><span class="hljs-built_in">DepositMadeEvent</span>(<span class="hljs-number">12345</span>, <span class="hljs-number">100.00</span>, <span class="hljs-number">2023</span>-<span class="hljs-number">10</span>-<span class="hljs-number">04</span>T12:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>Z) <span class="hljs-built_in">WithdrawalMadeEvent</span>(<span class="hljs-number">12345</span>, <span class="hljs-number">50.00</span>, <span class="hljs-number">2023</span>-<span class="hljs-number">10</span>-<span class="hljs-number">05</span>T10:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>Z) <span class="hljs-built_in">InterestAccruedEvent</span>(<span class="hljs-number">12345</span>, <span class="hljs-number">0.50</span>, <span class="hljs-number">2023</span>-<span class="hljs-number">10</span>-<span class="hljs-number">06</span>T00:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>Z)</pre></div><p id="384f">The current balance of account 12345 would be 149.50.</p><h2 id="9bba">Event Sourcing Key Concepts:</h2><blockquote id="bdf0"><p><b><i>Events</i></b><i> Events are the fundamental building blocks of event sourcing. They represent atomic state changes that occur within a system. Each event encapsulates the details of a specific change, such as a deposit made to an account or a product added to a cart.</i></p></blockquote><blockquote id="e74f"><p><b><i>Event Store</i></b><i> The event store serves as the central repository for events. It persistently stores events in an append-only manner, ensuring the integrity and immutability of the event stream. This chronological record of events provides a comprehensive audit trail of system state changes.</i></p></blockquote><blockquote id="6323"><p><b><i>Event Stream</i></b><i> An event stream is an ordered sequence of events for a particular entity or process. It represents the complete history of changes for that entity, allowing for reconstruction of the system state at any point in time. The chronological ordering of events is crucial for understanding the causal relationships between changes.</i></p></blockquote><h1 id="4081">Architecting for Event Sourcing</h1><p id="b356">In systems utilizing event sourcing, a key difference lies in how data is stored. Unlike traditional relational databases that emphasize the current state of data, event sourcing prioritizes preserving the sequence of events causing state changes. This shift in data management requires a carefully structured architecture to handle both data manipulation and retrieval effectively. Consequently, an event-sourced system neatly divides into two distinct components — <b>command </b>and <b>query</b>.</p><figure id="00dd"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*1MH4-bsYG_TNpNn-_HIIww.png"><figcaption><b>Event Sourcing System</b></figcaption></figure><p id="bc30">The <b>command </b>side manages user interactions, translating them into e

Options

vents that indicate intended changes to the system’s state. As the data entry point, it rigorously validates incoming commands before creating and preserving events. Validated events are then stored in the event store, ensuring a secure and unchangeable system record.</p><p id="93a8">On the other hand, the <b>query </b>side exclusively retrieves and presents user data. Focused on constructing view models tailored to the client’s needs, it extracts relevant information from the event stream. This process reconstructs the system’s current state using the chronological sequence of events. Additionally, the query side can notify the client of new events for real-time updates to the user interface.</p><p id="6148"><b>Event Store </b>At the heart of event sourcing lies the event store, a specialized database designed to persistently store events in an append-only manner. This immutable repository serves as the system’s historical backbone, safeguarding the chronological sequence of events that have transpired. The event store’s primary responsibilities include:</p><ul><li><b>Event Persistence</b>: Ensures the durability and integrity of events by storing them in a tamper-proof manner.</li><li><b>Event Ordering</b>: Maintains the chronological order of events, preserving the causal relationships between them.</li><li><b>Event Retrieval</b>: Provides efficient access to events for processing, analysis, or replaying to reconstruct system state.</li></ul><p id="1369"><b>Materialized Views </b>Materialized views, also known as read models, are derived representations of the current state of the system, constructed and maintained by consuming events from the event store. They offer optimized data access for read-heavy operations, enabling efficient retrieval of frequently queried information without the need to replay the entire event stream.</p><p id="aa28">CQRS (Command/Query Responsibility Segregation), with its separation of command and query responsibilities, plays a crucial role in utilizing materialized views effectively. The query side can independently manage and update materialized views based on incoming events, ensuring that the current state of the system is always readily accessible for read operations.</p><h1 id="0fa5">Event Sourcing in Action</h1><p id="b1ea"><b>Event sourcing and CQRS</b> have gained traction in various domains due to their ability to address the challenges of modern distributed systems. Here are a few examples:</p><ul><li><b>Financial Transactions</b> Event sourcing is widely used in financial systems to record and audit transactions, ensuring transparency and traceability.</li><li><b>E-commerce Platforms </b>Event sourcing enables e-commerce platforms to capture user interactions, order history, and product changes, facilitating real-time data analysis and personalization.</li><li><b>Social Media Networks</b> Event sourcing powers social media platforms to handle the vast volume of user activity, providing a scalable and auditable record of interactions.</li></ul><h1 id="57b6">Final Thoughts</h1><p id="f6e0">Event sourcing isn’t just a trend; it’s a game-changer. It gives developers the power to build systems that don’t just handle challenges but excel in resilience and scalability. Imagine a system that keeps a perfect historical record, gracefully deals with hiccups, and smoothly adapts to changes without missing a beat. That’s what Event Sourcing brings to the table. As the need for robust and scalable systems keeps growing, Event Sourcing is becoming the go-to, making its mark as a must-have in the modern software toolkit.</p><p id="f78b"><b>Until our next adventure, stay connected, stay reliable, and keep rocking the digital world! 🚀🌐💻</b></p><p id="1e51">👏 Feel free to give it a friendly round of <b>applause </b>and hit that ‘<b>Follow</b>’ button for more engaging content. Your support truly means the world!</p></article></body>

How To Deal With Loneliness When Living Alone

by Hannah Callisto

As I write this, I am sitting on a wooden chair in the apartment that I rent, and everything is so quiet. I can precisely isolate each sound. Cars passing by are a constant here. The clock ticking reminds me that time goes by, and I have only an hour to finish this before work. The fridge is buzzing, and I bet it’s the loneliest sound ever; you can hear it only when you are all alone.

I work from home, but I have two desks. To be precise, a desk and a kitchen table. I write from a kitchen table; it feels more cozy and casual, as I’d like my writing to be. Comforting and warm, like a scarf on a cold winter day. Or like someone who understands you and knows how to comfort you.

Living alone is a lonely feeling. Going to bed alone, returning home to an empty apartment, and navigating through daily routines without the presence of others create a profound sense of isolation.

Here are some tips on how to deal with loneliness when living alone.

Practical ways to beat loneliness if you live alone

Go outside every day, even if it’s just for a quick walk or run around the neighbourhood. Spending too much time alone in your apartment is unhealthy and will do nothing but make your loneliness worse.

Keep a to-do list. I try to maintain a good structure throughout the week to keep my mind distracted and to have a sense of routine.

Let the light in. I don’t have curtains. I like to let the light in, and usually, in the morning, I open the windows and observe the world while drinking coffee.

Get lost in a good book or TV show. Sometimes, I binge-watch comforting shows like Friends. It reminds me that somewhere outside, there are people who can become my best friends.

Invite friends over for no reason. Host a Netflix binge-night, play some video games, organise a small party, whatever you feel like doing. You’ll be surprised how many people also feel alone and would like to spend time with others.

Try eating out alone. It can feel awkward, but I am sure you will feel better after it and start enjoying it after some time. It’s also an opportunity to connect with people and start a new friendship. If you keep going back to your favourite coffee shop, the staff may start to recognize you, and you may recognize familiar faces and start a new friendship or relationship.

Make a dinner for yourself. Recently, I started cooking and preparing my meals. I used to buy food, but the smell of the food always makes home feel more like home. I am still a beginner, I can make only a few basic meals, but I am learning.

Despite everything, there’s a peculiar sense of freedom in this solitude. It’s a freedom that allows for personal space to organize my time and surroundings exactly as I desire. I can leave my apartment as clean or as dirty as I want to. I am not a huge fan of this, but with a good structure and routine, I find it easier to cope with loneliness.

Loneliness
Life
Personal Development
Mental Health
Routine
Recommended from ReadMedium