Comments (5)
Hi @wapiflapi thanks for noticing and looking into this issue, and describing it so well.
Sorry for the delay in responding. I was just away on an extended summer break. I'm back now.
The solution you propose, of passing in the mapper class, seems good to me. It's a very simple fix, so long as all the applications are using the same type of mapper. The example doesn't really go as far as you have taken this.
I suppose if we wanted to support applications using different mapper classes, then we could specify the mapper classes as topics in the environment. And then have the factory resolving the topics to mapper classes. With the solution you provided as the default, where they all use the same class.
I've just made the change you suggested in the code, and everything seems to work okay! I will release a new version with this small change, and think about supporting different mapper classes in future.
from eventsourcing.
@johnbywater if using self.construct_mapper()
in the Follower(Application)
seems to you to be the right thing to do, I'd be happy to send a PR your way.
from eventsourcing.
While writing a fix for this on my Application inheriting from ProcessApplication I came up with:
class MyApplication(ProcessApplication):
# Fixing a bug (?) in eventsourcing.
def follow(self, name: str, log: NotificationLog) -> None:
"""
Constructs a notification log reader and a mapper for
the named application, and adds them to its collections
of readers and mappers.
"""
assert isinstance(self.recorder, ProcessRecorder)
reader = NotificationLogReader(log, section_size=self.pull_section_size)
env = self.construct_env(name, self.env)
factory = self.construct_factory(env)
mapper = factory.mapper(self.construct_transcoder(), type(self.mapper))
self.readers[name] = reader
self.mappers[name] = mapper
The important line is:
mapper = factory.mapper(self.construct_transcoder(), type(self.mapper))
That might be somewhat cleaner, since it still uses the factory that is built for the env
related to name
, instead of our own.
To be honnest I don't understand enough about the implications of this to have an opinion on if this is safe or not but ...
from eventsourcing.
Actually, MAPPER_TOPIC, CIPHER_TOPIC and COMRESSOR_TOPIC are defined but only CIPHER_TOPIC and COMPRESSOR_TOPIC are used. So I guess I was thinking (in 2021) to implement this but didn't get around to it. I think it would be quite easy to implement support for MAPPER_TOPIC and also TRANSCODER_TOPIC, along the same lines, that is to read the environment and resolve the topic if defined and otherwise use the default or given class, so that different applications can use different types of these things and still work together in a system.
from eventsourcing.
Changes above released as v9.2.21:
https://pypi.org/project/eventsourcing/9.2.21/
https://eventsourcing.readthedocs.io/en/stable/topics/release_notes.html#version-9-2-21-released-13-oct-2023
from eventsourcing.
Related Issues (20)
- Postgres does not accept idle_in_transaction_session_timeout as float string HOT 2
- Postgres schema change possibility HOT 5
- Investigating potential problem when saving events for multiple aggregates HOT 2
- Custom Postgres schema breaks followers HOT 3
- Aggregate Not Found when AGGREGATE_CACHE_MAXSIZE not set HOT 13
- monotonic HOT 2
- support postgresql as alias for postgres persistence module HOT 3
- Support for rabbitmq HOT 10
- Best way to befriend sqlalchemy database and eventsourcing HOT 6
- Is it necessary to re-hydrate an aggregate to check it exists in a repository? HOT 4
- Suggested approach to Entities in 9.x? HOT 1
- Slack invite not working HOT 3
- Snapshot in aggregate8 example won't work for custom object in aggregate HOT 8
- Additional examples HOT 2
- How to set aggregate/application state for tests? HOT 1
- Automatic snapshotting not work for functional style aggregate HOT 8
- Use ProcessApplication build materialized view HOT 2
- Question: How to best integrate with token based authentication for Postgres HOT 16
- Question: how to avoid performance bottleneck with huge number of events HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventsourcing.