GithubHelp home page GithubHelp logo

Comments (5)

johnbywater avatar johnbywater commented on June 10, 2024 1

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.

wapiflapi avatar wapiflapi commented on June 10, 2024

@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.

wapiflapi avatar wapiflapi commented on June 10, 2024

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.

johnbywater avatar johnbywater commented on June 10, 2024

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.

johnbywater avatar johnbywater commented on June 10, 2024

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)

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.