Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parse topic events without struct fields #137

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nitric/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from nitric.proto.topics.v1 import ClientMessage as TopicClientMessage
from nitric.proto.topics.v1 import MessageResponse as TopicResponse
from nitric.proto.topics.v1 import ServerMessage as TopicServerMessage
from nitric.utils import dict_from_struct

Record = Dict[str, Union[str, List[str]]]
PROPAGATOR = propagate.get_global_textmap()
Expand Down Expand Up @@ -173,7 +174,7 @@ def _from_request(msg: TopicServerMessage) -> MessageContext:
"""Construct a new EventContext from a Topic trigger from the Nitric Membrane."""
return MessageContext(
request=MessageRequest(
data=msg.message_request.message.struct_payload.to_dict(),
data=dict_from_struct(msg.message_request.message.struct_payload),
topic=msg.message_request.topic_name,
)
)
Expand Down
4 changes: 2 additions & 2 deletions nitric/resources/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from nitric.proto.topics.v1 import RegistrationRequest, SubscriberStub
from nitric.proto.topics.v1 import TopicPublishRequest, TopicsStub
from nitric.resources.resource import SecureResource
from nitric.utils import new_default_channel, struct_from_dict
from nitric.utils import dict_from_struct, new_default_channel, struct_from_dict

TopicPermission = Literal["publish"]

Expand Down Expand Up @@ -131,7 +131,7 @@ def decorator(func: EventHandler) -> None:
def _message_context_from_proto(msg: ProtoMessageRequest) -> MessageContext:
return MessageContext(
request=MessageRequest(
data=msg.message.struct_payload.to_dict(),
data=dict_from_struct(msg.message.struct_payload),
topic=msg.topic_name,
)
)
Expand Down
Loading