Skip to content

WIP #87

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

WIP #87

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
9 changes: 8 additions & 1 deletion lib/Mojo/WebSocketProxy/Backend/ConsumerGroups.pm
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ Subscription will be done only once within first request to backend server.

sub wait_for_messages {
my ($self) = @_;
$self->{already_waiting} //= $self->redis->subscribe([$self->whoami], $self->redis->curry::weak::on(message => $self->curry::weak::_on_message));
$self->{already_waiting} //=
$self->redis->subscribe(['myriad.' . $self->whoami, $self->whoami],
Copy link

@billmarriott-deriv billmarriott-deriv Apr 26, 2022

Choose a reason for hiding this comment

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

Is it possible to only add the prefix based on msg_group so we can subscribe to a single channel?

Copy link
Author

@mahrous-deriv mahrous-deriv Apr 26, 2022

Choose a reason for hiding this comment

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

Yes, we can also pass the prefix from our API and prepend it to $self->whoami.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not add myriad hardcoded in proxy, it's an open source module. Pass it as a config or as a parameter

Copy link
Author

Choose a reason for hiding this comment

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

We can pass it from websocket.conf.

$self->redis->curry::weak::on(message => $self->curry::weak::_on_message));

return;
}
Expand All @@ -376,6 +378,11 @@ sub _on_message {

try {
$message = decode_json_utf8($raw_message);
if (ref $message->{args} ne 'HASH') {
$message->{args} = decode_json_utf8($message->{args});
$message->{response} = decode_json_utf8($message->{response});
$message->{response} = {result => $message->{response}{response}};
}
} catch {
my $err = $@;

Expand Down