Skip to content

Conversation

@ice-endymion
Copy link
Contributor

@ice-endymion ice-endymion commented Nov 13, 2025

Description

  • avoid parse to raw EventMessage by using original EventMessage

Task ID

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation
  • Chore

int get createdAt;

// The original event message that was used to create this entity.
EventMessage? get eventMessage;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Shouldn't there be a direct one-to-one mapping between EventMessage and the entity, both ways? Similar to how toJson and fromJson functions correspond with each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. The idea is to map an entity to an event message without spending resources on mapping using the original event.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ice-deimos
There might be corner cases - If the entity was changed over time, EventMessage generated by an old entity will differ with an EventMessage generated by the latest entity. That might lead to cases when
old EventMessage -> Entity -> EventMessage != old EventMessage

Plus it seems Entity -> EventMessage takes significant amount of resources, so when we call it frequently, for example when we write an entity to the db, it brings freezes.

But using original EventMessage has several flaws: it increases the overall memory usage + if entity was changed (with .copyWith for example, toEventMessage can't return the origianal EventMessage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants