Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Event Sourcing in Rails: Rebuilding Reality From a Stream of Truth

Your database is lying to you. Every UPDATE users SET status = 'banned' erases history. Every DELETE FROM orders is digital amnesia. What if instead: You could replay last month’s user signups to debug a fraud spike? Your audit log was y…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Your database is lying to you.



Every UPDATE users SET status = 'banned' erases history. Every DELETE FROM orders is digital amnesia. What if instead:




  • You could replay last month’s user signups to debug a fraud spike?

  • Your audit log was your database?

  • Undoing production mistakes meant rewinding events, not restoring backups?



Event Sourcing makes this possible. Here’s how to implement it in Rails—without rewriting your app.









Why Event Sourcing?






The Problems It Solves





  1. Lost Context: Traditional CRUD overwrites the "why" behind data changes.


  2. Debugging Nightmares: "How did this order total become $0?" requires forensic SQL.


  3. Temporal Queries: "Show me all users who were active last Tuesday at 3 PM."






When to Use It



✅ Financial systems (non-repudiation is critical)

✅ Regulated industries (audit trails by design)

✅ Complex workflows (e.g., order fulfillment with rollbacks)



When to Avoid:

❌ Basic CRUD apps (overkill for todo lists)

❌ Low-latency requirements (event rebuilding adds overhead)







Core Concepts





1. Events Are Your Source of Truth



Instead of:




UPDATE accounts SET balance = 100 WHERE id = 123;






You store:




AccountBalanceDeposited.new(account_id: 123, amount: 100, timestamp: Time.now)









2. Projections Rebuild State



Need the current balance? Reducing all events:




events = EventStore.for(account_id: 123)
balance = events.reduce(0) { |sum, event| sum + event.amount }









3. Commands Validate Before Events






class DepositMoney
def call(account_id, amount)
raise "Negative deposit" if amount < 0
EventStore.publish(AccountBalanceDeposited.new(account_id:, amount:))
end
end












Implementing in Rails






Step 1: Choose an Event Store








Step 2: Model Your Events






# app/events/account_balance_deposited.rb
class AccountBalanceDeposited < RailsEventStore::Event
def schema
{
account_id: String,
amount: Integer,
timestamp: Time
}
end
end









Step 3: Build Projections






# app/projections/account_balance.rb
class AccountBalance
def initialize(account_id)
@events = EventStore.for(account_id: account_id)
end

def current_balance
@events.sum(&:amount)
end

def as_of(timestamp)
@events.up_to(timestamp).sum(&:amount)
end
end









Step 4: Handle Side Effects



Subscribe to events asynchronously:




Rails.configuration.event_store.subscribe(
SendDepositNotification,
to: [AccountBalanceDeposited]
)












Advanced Patterns






1. Snapshots (For Performance)



Rebuilding from 10,000 events? Periodically save state:




Snapshot.create!(
aggregate_id: account_id,
data: { balance: 100 },
version: 42
)









2. CQRS (Command Query Responsibility Segregation)





  • Write Model: Handles commands → emits events.


  • Read Model: Optimized projections (e.g., materialized views).






3. Schema Evolution



Need to change an event? Use upcasters:




class AccountBalanceDeposited
def upcast(old_event)
old_event.data.merge(new_field: "default")
end
end












Pitfalls to Avoid





  • Event Spaghetti: Keep events small and focused.


  • Over-Engineering: Start with a single event stream.


  • Ignoring Idempotency: Design for replay safety.









Suggested Next Topics




  1. "Event Sourcing vs. CRUD: When 1000 Database Writes Don’t Matter"

  2. "CQRS in Rails: Scaling Reads and Writes Independently"

  3. "From Events to APIs: Building a REST Layer on Event Sourcing"

  4. "Testing Event-Sourced Systems: No More Fixtures, Just Replays"

  5. "When Event Sourcing Fails: War Stories from Production"






"But ActiveRecord Is Our Truth!"



It still can be. Event sourcing augments—it doesn’t require burning your CRUD models. Start small:




  1. Add event publishing to one critical model.

  2. Keep using ActiveRecord for queries.

  3. Gradually shift logic to projections.



Have you tried event sourcing? Share your "aha" moment (or horror story) below.

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - Event Sourcing in Rails: Rebuilding Reality From a Stream of Truth
id: 130aeba4-6547-412b-9687-adfda0a17a48
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "Event Sourcing in Rails: Rebui" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Event Sourcing in Rails Rebuilding Reali")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Event Sourcing in Rails Rebuilding Reali*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Event Sourcing in Rails Rebuilding Reali"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Event Sourcing in Rails: Rebuilding Real.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Event Sourcing in Rails: Rebuilding Reality From a Stream of Truth

Thematisch verwandte Begriffe: Event, Sourcing, Rails, Rebuilding · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-100372 | ClipBucket v5 before 5.5.3-#197 contains a path traversal vulnerability…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag