All Projects → chop-dbhi → eda

chop-dbhi / eda

Licence: MIT license
eda is a library for implementing event-driven architectures.

Programming Languages

go
31211 projects - #10 most used programming language
Protocol Buffer
295 projects

Projects that are alternatives of or similar to eda

Eventflow.example
DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.
Stars: ✭ 131 (+322.58%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
dudulina
CQRS + Event Sourcing library for PHP
Stars: ✭ 53 (+70.97%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Event Sourcing Jambo
An Hexagonal Architecture with DDD + Aggregates + Event Sourcing using .NET Core, Kafka e MongoDB (Blog Engine)
Stars: ✭ 159 (+412.9%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Event Source Cqrs Sample
Sample ES/CQRS application
Stars: ✭ 380 (+1125.81%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Foxoffice
Sample application demonstrating how to build a distributed cloud .NET Core application based on CQRS and Event Sourcing.
Stars: ✭ 33 (+6.45%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (+635.48%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Goes
Go Event Sourcing made easy
Stars: ✭ 144 (+364.52%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Akkatecture
a cqrs and event sourcing framework for dotnet core using akka.net
Stars: ✭ 414 (+1235.48%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Rails event store
A Ruby implementation of an Event Store based on Active Record
Stars: ✭ 947 (+2954.84%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Asombroso Ddd
Una lista cuidadosamente curada de recursos sobre Domain Driven Design, Eventos, Event Sourcing, Command Query Responsibility Segregation (CQRS).
Stars: ✭ 41 (+32.26%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Event Sourcing Castanha
An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
Stars: ✭ 68 (+119.35%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing, event-driven
Booster
Booster Cloud Framework
Stars: ✭ 136 (+338.71%)
Mutual labels:  cqrs, event-sourcing, event-driven
Symfony Demo App
A Symfony demo application with basic user management
Stars: ✭ 122 (+293.55%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing
Vertex
Vertex is a distributed, ultimately consistent, event traceable cross platform framework based on Orleans, which is used to build high-performance, high throughput, low latency, scalable distributed applications
Stars: ✭ 117 (+277.42%)
Mutual labels:  cqrs, event-sourcing, event-driven
Revo
Event Sourcing, CQRS and DDD framework for C#/.NET Core.
Stars: ✭ 162 (+422.58%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing
Kreta
Modern project management solution
Stars: ✭ 177 (+470.97%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing
Watermill
Building event-driven applications the easy way in Go.
Stars: ✭ 3,504 (+11203.23%)
Mutual labels:  cqrs, event-sourcing, event-driven
User Bundle
A new Symfony user bundle
Stars: ✭ 116 (+274.19%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing
Event Sourcing Microservices Example
Learn about building microservices with event sourcing using Spring Boot and how to deploy a social network to Kubernetes using Docker Compose or Helm.
Stars: ✭ 167 (+438.71%)
Mutual labels:  cqrs, event-sourcing, event-driven
nest-convoy
[WIP] An opinionated framework for building distributed domain driven systems using microservices architecture
Stars: ✭ 20 (-35.48%)
Mutual labels:  cqrs, domain-driven-design, event-sourcing

eda

License MIT Go Report Card Build Status GoDoc

eda is a library for implementing event-driven architectures. It provides a thin layer on top of backends that support ordered, durable streams with a publish/subscribe interface. The current implementation uses NATS Streaming as a backend.

Status

The library is in an Alpha stage and looking feedback and discussions on API design and scope. Check out the issues for topics.

Use Case

The primary use case this library is being designed to support are applications involving "domain events". That is, these events carry information about something that occurred in a domain model that must be made available for other consumers.

One application of this is as a building block for systems using CQRS pattern where events produced on the write side (a result of handling a command) need to get published so the read side can consume and update their internal indexes.

Another related use case is Event Sourcing which are generally spoken of in the context of an "aggregate". The pattern requires each aggregate instance to maintain it's own stream of events acting as an internal changelog. This stream is generally "private" from other consumers and requires having a single handler to apply events in order to maintain a consistent internal state.

This library could be used for this, but the backends do not currently generalize well to 10's or 100's of thousands of streams. One strategy is "multi-plex" events from multiple aggregates on a single stream and have handlers that ignore events that are specific to the target aggregate. The basic trade-off are the number of streams (which may be limited by the backend) and the latency of reading events on a multi-plexed stream.

Examples

See the examples directory.

Install

Requires Go 1.9+

go get -u github.com/chop-dbhi/eda/...

Backend

This library relies on NATS Streaming as a backend. There are ways of running the server:

In any case, the suggested command line options for full durability:

$ nats-streaming-server \
  --cluster_id test-cluster \
  --store file \
  --dir data \
  --max_channels 0 \
  --max_subs 0 \
  --max_msgs 0 \
  --max_bytes 0 \
  --max_age 0s \

Get Started

Connecting to the backend

The first step is to establish a connection to the NATS Streaming server. Below uses the default address and cluster ID. Connect also takes a client ID which identifies the connection itself. Be thoughtful of the client ID since it will be used as part of the key for tracking progress in streams for subscribers. It is also added to events published by this connection for traceability.

// Establish a connection to NATS specifiying the server address, the cluster
// ID , and a client ID for this connection.
conn, _ := eda.Connect(
  "nats://localhost:4222",
  "test-cluster",
  "test-client",
)

// Close on exit.
defer conn.Close()

Publishing events

To publish an event, simply use the Publish method passing an Event value.

id, _ := conn.Publish("subjects", &eda.Event{
  Type: "subject-enrolled",
  Data: eda.JSON(&Subject{
    ID: "3292329",
  }),
})

By convention, Type should be past tense since it is describing something that already happened. The event Data should provide sufficient information on the event for consumers. There are helper functions to encode bytes, strings, JSON, and Protocol Buffer types.

A couple additional fields can be supplied including Cause which is an identifier of the upstream event (or something else) that caused this event and Meta which is a map of arbitrary key-value pairs for additional information.

Returned is the unique ID of the event and an error if publishing to the server failed.

Consuming events

The first thing to do is create a Handler function that will be used to handle events as they are received from the server. You can see the signature of the handler below which includes a context.Context value and the received event.

handle := func(ctx context.Context, evt *eda.Event) error {
  switch evt.Type {
  case "subject-enrolled":
    var s Subject
    if err := evt.Data.Decode(&s); err != nil {
      return err
    }

    // Do something with subject.
  }

  return nil
}

To start receiving events, a subscription needs to be created which takes the name of the stream to subscribe to, the handler, and subscription options.

sub, _ := conn.Subscribe("subjects", handle, *eda.SubscriptionOptions{
  Backfill: true,
  Durable: true,
  Serial: true,
})
defer sub.Close()

In this case, we want to ensure we process events in order even if an error occurs. We want to read the backfill of events in the stream to "catch-up" to the current state, and make the subscription durable so reconnects start where they are left off.

Learn More

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].