Git Product home page Git Product logo

beeline's Introduction

Beeline

Actions CI

a tool for building in-order GenStage topologies for EventStoreDB1

Installation

def deps do
  [
    {:beeline, "~> 1.0"},
    # these are optional: add whichever adapter your project needs
    {:kelvin, "~> 1.0"},
    {:volley, "~> 1.0"}
  ]
end

Check out the docs here: https://hexdocs.pm/beeline

Usage

Beeline is a Broadway-like library for building in-order event-processors for EventStoreDB. Writing a Beeline topology is roughly the same as writing a GenStage consumer but with more configuration in the start_link/1 function.

defmodule MyApp.MyEventHandler do
  use Beeline

  def start_link(_opts) do
    Beeline.start_link(__MODULE__,
      name: __MODULE__,
      producers: [
        default: [
          adapter: :kelvin,
          stream_name: "$ce-BoundedContext.Aggregate",
          connection: MyApp.ExtremeClient
        ]
      ],
      get_stream_position: fn producer ->
        MyApp.Repo.get(MyApp.StreamPosition, inspect(producer))
      end
    )
  end

  @impl GenStage
  def handle_events(subscription_events, _from, state) do
    # do something with the events

    {:noreply, [], state}
  end
end

See the hex documentation for Beeline.start_link/2 for the configuration schema and explanation.

Why in-order?

Beeline champions in-order procesing because it can vastly simplify the writing of event processing code. By forcing strictly in-order processing, Beeline can guarantee either that all events in the stream will be handled in-order and exactly once or that the processor will halt. This avoids any potential concurrency dragons and allows an author to make assumptions about ordering.

In-order subscriptions are also very inexpensive on the EventStoreDB: stream reads and basic subscriptions cost next to nothing in terms of resources.

What if I want more complex topologies?

If you want multiple consumers or a pipeline with producer-consumers, you can write the topology using straight-up GenStage, Kelvin/Volley, and a Supervisor. Beeline is meant to be a convenience library for gluing together the most common processes and configuration for a simple in-order subscription.

If you want to handle events out of order with concurrency and batching, Broadway is an excellent choice when paired with the EventStoreDB persistent subscriptions feature. Broadway's acknowledgement system fits perfectly with the persistent subscriptions API.

Footnotes

  1. not to bee confused with honeycomb beelines โ†ฉ

beeline's People

Contributors

bjornrud avatar burmajam avatar electricshaman avatar mpran avatar pmonson711 avatar svrdlans avatar the-mikedavis avatar tonyvanriet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.