Skip to content

Commit

Permalink
Miscellaneous bug fixes for message and versioning compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
subhashb committed Feb 18, 2022
1 parent 017ea5e commit 4734377
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/protean/adapters/broker/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def register(self, initiator_cls, consumer_cls):

def publish(self, message: Message) -> None:
event_cls = fetch_element_cls_from_registry(
message["name"], (DomainObjects.EVENT,)
message.type, (DomainObjects.EVENT,)
)
for subscriber in self._subscribers[fully_qualified_name(event_cls)]:
if self.conn_info["IS_ASYNC"]:
Expand Down
5 changes: 3 additions & 2 deletions src/protean/adapters/repository/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ def to_entity(cls, item: "ElasticsearchModel"):
id_field_name = id_field(cls.meta_.entity_cls).field_name
item_dict[id_field_name] = identifier

# Set version from document meta
item_dict["_version"] = item.meta.version
# Set version from document meta, only if `_version` attr is present
if hasattr(cls.meta_.entity_cls, "_version"):
item_dict["_version"] = item.meta.version

entity_obj = cls.meta_.entity_cls(item_dict)

Expand Down

0 comments on commit 4734377

Please sign in to comment.