GithubHelp home page GithubHelp logo

Comments (2)

johnbywater avatar johnbywater commented on June 26, 2024

Thanks for asking!

I think we are interested to support any reliable database management system that is capable of supporting atomic transactions and uniqueness constraints.

The library's "aggregate recorder" class can be implemented on most databases. If the DBMS doesn't support atomic transactions on multiple aggregate sequences, then the aggregste recorder will need to make this apparent, somehow, to avoid potential inconsistency.

If the DBMS supports auto-incrementing a counter, or otherwise putting the aggregate events in a "total order", the aggregate recorder can be extended to implement an "application recorder". This allows the state of an application (domain model comprising many aggregates) to be propagated reliably. An application recorder is the type of recorder normally used by an application class.

If the DBMS also allows tracking records to be written atomically with new state (aggregate events, materialized views, etc), then the application recorder can be extended to implement a "process recorder". A process recorder is the type of recorder normally used by a "process application" in an event processing system.

So, yes, to the extent that MongoDB is capable of supporting these things, there is interest in adapting it to work with the library.

If you are interested to help with this, please let me know. I don't have much experience with MongoDB.

from eventsourcing.

byt3-m3 avatar byt3-m3 commented on June 26, 2024

Hey John,
Thank you for the information. I will keep this in mind, as I plan to write a mongo recorder for this repo. I am working on an app right now using this library. I actually just implemented my own Mongodb recorder, but I can easily submit a more final product to the codebase.

class MongoRecorder(AggregateRecorder):
    def __init__(self, db_host, db_port):
        self._client = get_client(db_host=db_host, db_port=db_port)
        self._db = get_database(client=self._client, db_name='AggregateRecorder')
        self.collection = get_collection(database=self._db, collection='aggregate_events')

    def insert_events(self, stored_events: List[StoredEvent], **kwargs: Any) -> None:
        results = add_many_items(
            collection=self.collection,
            items=[asdict(event) for event in stored_events],
            ordered=True
        )

    def select_events(
            self,
            originator_id: UUID,
            gt: Optional[int] = None,
            lte: Optional[int] = None,
            desc: bool = False,
            limit: Optional[int] = None,
    ) -> List[StoredEvent]:
        cursor = get_item(collection=self.collection, item_id=originator_id, item_key='originator_id')

        return [
            StoredEvent(
                originator_id=record['originator_id'],
                topic=record['topic'],
                originator_version=record['originator_version'],
                state=bytes(record['state'])
            ) for record in cursor
        ]

from eventsourcing.

Related Issues (20)

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.