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

RFC: Allow topic extraction via json::decode() #443

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

awelzel
Copy link
Contributor

@awelzel awelzel commented Jan 23, 2025

Hey @Neverlord - I'm attempting to use broker::format::json::v1::decode() to decode Zeek events sent by external clients, but implemented outside of the Broker layer. The Broker WebSocket format defines the "topic" a client publishes to, to be part of the top-level JSON object.

This PR changes decode() to optionally support extracting the topic, too. Does this feel too ad-hoc? I realize decode() can decode non-events, too, so maybe adding a separate helper would be the better approach?

It's this part from the internal/json_client.cc, but it has a parsed JSON representation available:

auto maybe_msg = data_envelope::deserialize(
id, endpoint_id::nil(), defaults::ttl,
caf::to_string(obj.value("topic").to_string()), buf.data(), buf.size());

@awelzel awelzel marked this pull request as draft January 23, 2025 10:08
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.

1 participant