Git Product home page Git Product logo

commanded-spear-adapter's Introduction

CI Hex.pm Hex Docs

Spear EventStoreDB adapter for Commanded

Commanded EvenstoreDB adapter based on spear. The code is based on commanded-extreme-adapter.


Hex package

Changelog


Getting started

The package can be installed from hex as follows.

  1. Add commanded_spear_adapter to your list of dependencies in mix.exs:

    def deps do
      [{:commanded_spear_adapter, "~> 0.2"}]
    end
  2. Define and configure your Commanded application:

    defmodule MyApp.Application do
      use Commanded.Application, otp_app: :my_app
    end
  3. Configure the Commanded application to use the Commanded.EventStore.Adapters.Spear adapter and set the connection settings for the Event Store you are using:

    # config/config.exs
    config :my_app, MyApp.Application,
      event_store: [
        adapter: Commanded.EventStore.Adapters.Spear,
        serializer: Commanded.Serialization.JsonSerializer,
        stream_prefix: "myapp",
        spear: [
          connection_string: "esdb://localhost:2113"
        ]
      ]

    Refer to the Spear library documentation for details on the available connection settings.

    Note: Stream prefix must not contain a dash character ("-").

Partition

This adapter does not support partitioning via the partition_by option.

Multi-node setup

commanded_spear_adapter uses Erlang's :global registry to prevent duplicate subscriptions by stream/name.

Use a serializer other than JSON

To serialize and deserialize events in formats other than JSON, you must specify the content-type of the event body.

# config/config.exs
config :my_app, MyApp.Application,
  event_store: [
    adapter: Commanded.EventStore.Adapters.Spear,
    serializer: MyApp.MessagePackSerializer,
    content_type: "application/x-msgpack"
    ...
  ]

The content_type settings defaults to application/json.

Running the Event Store

You must run the Event Store with all projections enabled and standard projections started.

Use the --run-projections=all --start-standard-projections=true flags when running the Event Store executable.

Credits

commanded-spear-adapter's People

Contributors

fabriziosestito avatar dependabot[bot] avatar dvic avatar philipgiuliani 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.