example

A simple, unit-tested, event sourced application.

domainmodel

class eventsourcing.example.domainmodel.Example(foo='', a='', b='', **kwargs)[source]

Bases: eventsourcing.domain.model.entity.EntityWithHashchain, eventsourcing.domain.model.entity.TimestampedVersionedEntity

An example event sourced domain model entity.

class Event(**kwargs)[source]

Bases: eventsourcing.domain.model.entity.Event, eventsourcing.domain.model.entity.Event

Supertype for events of example entities.

class Created(**kwargs)[source]

Bases: eventsourcing.example.domainmodel.Event, eventsourcing.domain.model.entity.Created, eventsourcing.domain.model.entity.Created

Published when an Example is created.

class AttributeChanged(**kwargs)[source]

Bases: eventsourcing.example.domainmodel.Event, eventsourcing.domain.model.entity.AttributeChanged

Published when an Example is created.

class Discarded(**kwargs)[source]

Bases: eventsourcing.example.domainmodel.Event, eventsourcing.domain.model.entity.Discarded

Published when an Example is discarded.

class Heartbeat(**kwargs)[source]

Bases: eventsourcing.example.domainmodel.Event, eventsourcing.domain.model.entity.Event

Published when a heartbeat in the entity occurs (see below).

mutate(obj)[source]

Updates ‘obj’ with values from self.

__init__(foo='', a='', b='', **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

foo

An example attribute.

a

An example attribute.

b

Another example attribute.

eventsourcing.example.domainmodel.create_new_example(foo='', a='', b='')[source]

Factory method for example entities.

Return type:Example

infrastructure

class eventsourcing.example.infrastructure.ExampleRepository(event_store, use_cache=False, **kwargs)[source]

Bases: eventsourcing.infrastructure.eventsourcedrepository.EventSourcedRepository, eventsourcing.example.domainmodel.AbstractExampleRepository

Event sourced repository for the Example domain model entity.

application

class eventsourcing.example.application.ApplicationWithEventStores(entity_record_manager=None, log_record_manager=None, snapshot_record_manager=None, cipher=None, sequenced_item_mapper_class=<class 'eventsourcing.infrastructure.sequenceditemmapper.SequencedItemMapper'>)[source]

Bases: abc.ABC

Event sourced application object class.

Can construct event stores using given database records. Supports three different event stores: for log events, for entity events, and for snapshot events.

__init__(entity_record_manager=None, log_record_manager=None, snapshot_record_manager=None, cipher=None, sequenced_item_mapper_class=<class 'eventsourcing.infrastructure.sequenceditemmapper.SequencedItemMapper'>)[source]

Initialize self. See help(type(self)) for accurate signature.

class eventsourcing.example.application.ApplicationWithPersistencePolicies(**kwargs)[source]

Bases: eventsourcing.example.application.ApplicationWithEventStores

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

class eventsourcing.example.application.ExampleApplication(**kwargs)[source]

Bases: eventsourcing.example.application.ApplicationWithPersistencePolicies

Example event sourced application with entity factory and repository.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

create_new_example(foo='', a='', b='')[source]

Entity object factory.

eventsourcing.example.application.construct_example_application(**kwargs)[source]

Application object factory.

eventsourcing.example.application.init_example_application(**kwargs)[source]

Constructs single global instance of application.

To be called when initialising a worker process.

eventsourcing.example.application.get_example_application()[source]

Returns single global instance of application.

To be called when handling a worker request, if required.

eventsourcing.example.application.close_example_application()[source]

Shuts down single global instance of application.

To be called when tearing down, perhaps between tests, in order to allow a subsequent call to init_example_application().

interface

class eventsourcing.example.interface.flaskapp.IntegerSequencedItem(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Model

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.