Giter VIP home page Giter VIP logo

fs2-es's Introduction

FS2-ES

This project is not actively maintained as of October 2021, and should be avoided for new projects at this time. If you are looking for event-sourcing needs in the Typelevel ecosystem, please check out edomata instead.

Sonatype Nexus (Releases) Gitter

This is a small library to encode event-sourcing patterns using FS2, a streaming library in Scala. The library is polymorphic using Cats Effect, so you can use it with any effect type you want that implements cats.effect.Concurrent.

To use, add the library to your build.sbt like so:

libraryDependencies += "dev.rpeters" %% "fs2-es" % "<latest-version>"
libraryDependencies += "dev.rpeters" %% "fs2-es-testing" % "<latest-version>" //Test module

Currently Scala 2.12 and 2.13 are both supported. Project is built for Scala JVM and ScalaJS 1.4+.

Features

This library has three core focuses:

  • State Management - Use "EventState" to model event-driven state that is safe, concurrent, and with no boilerplate.
  • Event Sourcing - Manage entities using event sourcing patterns with "EventStateCache", a standard repository interface.
  • Test Utilities - Utilize time-travel debugging features and other goodies to analyze your state as it changes.

Click any of the links above to go to the relevant parts of the documentation on our microsite.

API Docs

fs2-es's People

Contributors

scala-steward avatar sloshy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fs2-es's Issues

v1.0.0 Ideas

Besides what's already implemented on main, the following things would be nice to have before calling a v1.0.0 release:

  • At least one or two implementations of actual event logs, so files, kafka, DB table, maybe Cassandra.
  • Codecs, circe/binary would be a good start. Maybe protobuf or avro or something too.
  • Rename the lib to something that sounds less like it's about elasticsearch
  • Redo the docs
  • Do a video on it. Maybe buy a green screen for it so I can be over the presentation.
  • Machinery for "snapshotting" the event log.

Better MapRef performance

MapRef right now is kind of weird in that it's not the only implementation out there, and it could probably be implemented better besides. Right now it's a bit naive and will work up to a certain performance limit where you might want a "real" concurrent data structure. Look into alternatives to bring in, and if necessary create PRs for features to make them more like the one written here.

Set up microsite

It would look really nice if this project had a fancy microsite. Look at sbt-microsite, and also docusaurus. Will probably go with the latter. Wire in documentation, and maybe include some fancy GIFs and examples.

Build for ScalaJS

It'd be nice if it were possible to use FS2 ES in ScalaJS for state management. Maybe also consider including abstractions explicitly for this purpose.

Provide EventState[F].hydratedStream to keep everything streamy

Right now when creating a new EventState via hydrated it will .compile.drain the stream applying the events. This might not always be desirable, so provide a version where instead of running the stream separately it emits a single value of the final state. The current hydrated constructor can then just be based on it in turn.

Prevent cache misses in EventStateManager

Currently if one does N simultaneous requests to use an EventState through EventStateManager, it will evaluate the hydration stream up to N times, wasting resources. Thinking I should use Deferred or some other mechanism to synchronize access to state until after the first (and only) evaluation of the hydration stream.

Add documentation on checkpointing/snapshotting

As event-sourced state accrues more events, it's often required to make snapshots or checkpoints that represent partially-accumulated state to speed the process of rehydrating up. This library does not have an explicit snapshotting mechanism, but rather it assumes that a "snapshot event" is persisted in your incoming event stream. So what if you use a different location for your snapshots such as HDFS/S3? It's certainly doable, though it might be confusing for a newcomer. Write out some documentation on how this should be done, and if necessary figure out architectural changes in the library to make this a better-supported feature.

Reorganize documentation

A giant text blurb in a single README isn't the best kind of documentation. Ideally it should have sections that you can navigate to, and also possibly be built as a microsite. At the same time, take the opportunity to reword and make more approachable the underlying concepts of the library.

Support (E, A) methods in EventState

Sometimes it might be useful to know what event triggered what state. The internals of the various EventState implementations should be flexible enough to handle this option. In particular, this change would require rethinking the idea of an "initial state" to always require some incoming event. For the default case where there is no initial event, it can be modeled internally using Option[E] or something.

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.