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

MF-1091 - Use channels. as broker prefix #1098

Merged
merged 2 commits into from
Apr 6, 2020
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
13 changes: 7 additions & 6 deletions broker/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ type Nats interface {
}

const (
prefix = "channel"
chansPrefix = "channels"

// SubjectAllChannels define the subject to subscribe to all channels messages
SubjectAllChannels = "channel.>"
SubjectAllChannels = "channels.>"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please describe this PR, the purpose and reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nmarcetic this is more or less evident. channels.<chan_id> is to make it consistent with the public API (which is channels/<chan_id>, and not channel/<chan_id>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case I updated the description of the PR

)

var (
Expand Down Expand Up @@ -64,7 +65,7 @@ func (b broker) Publish(_ context.Context, _ string, msg Message) error {
return err
}

subject := fmt.Sprintf("%s.%s", prefix, msg.Channel)
subject := fmt.Sprintf("%s.%s", chansPrefix, msg.Channel)
if msg.Subtopic != "" {
subject = fmt.Sprintf("%s.%s", subject, msg.Subtopic)
}
Expand All @@ -75,9 +76,9 @@ func (b broker) Publish(_ context.Context, _ string, msg Message) error {
return nil
}

func (b broker) Subscribe(subject string, consumer func(msg *nats.Msg)) (*nats.Subscription, error) {
ps := fmt.Sprintf("%s.%s", prefix, subject)
sub, err := b.conn.Subscribe(ps, consumer)
func (b broker) Subscribe(subject string, f func(msg *nats.Msg)) (*nats.Subscription, error) {
ps := fmt.Sprintf("%s.%s", chansPrefix, subject)
sub, err := b.conn.Subscribe(ps, f)
if err != nil {
return nil, errors.Wrap(errNatsSub, err)
}
Expand Down
6 changes: 3 additions & 3 deletions docker/addons/cassandra-writer/subjects.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# If you want to listen on all subjects, just pass one element ["channel.>"], otherwise
# pass the list of subjects (e.g ["channel.<channel_id>", "channel.<channel_id>.sub.topic.x", ...]).
# If you want to listen on all subjects, just pass one element ["channels.>"], otherwise
# pass the list of subjects (e.g ["channels.<channel_id>", "channels.<channel_id>.sub.topic.x", ...]).
[subjects]
filter = ["channel.>"]
filter = ["channels.>"]
6 changes: 3 additions & 3 deletions docker/addons/influxdb-writer/subjects.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# If you want to listen on all subjects, just pass one element ["channel.>"], otherwise
# pass the list of subjects (e.g ["channel.<channel_id>", "channel.<channel_id>.sub.topic.x", ...]).
# If you want to listen on all subjects, just pass one element ["channels.>"], otherwise
# pass the list of subjects (e.g ["channels.<channel_id>", "channels.<channel_id>.sub.topic.x", ...]).
[subjects]
filter = ["channel.>"]
filter = ["channels.>"]
6 changes: 3 additions & 3 deletions docker/addons/mongodb-writer/subjects.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# If you want to listen on all subjects, just pass one element ["channel.>"], otherwise
# pass the list of subjects (e.g ["channel.<channel_id>", "channel.<channel_id>.sub.topic.x", ...]).
# If you want to listen on all subjects, just pass one element ["channels.>"], otherwise
# pass the list of subjects (e.g ["channels.<channel_id>", "channels.<channel_id>.sub.topic.x", ...]).
[subjects]
filter = ["channel.>"]
filter = ["channels.>"]
6 changes: 3 additions & 3 deletions docker/addons/postgres-writer/subjects.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# If you want to listen on all subjects, just pass one element ["channel.>"], otherwise
# pass the list of subjects (e.g ["channel.<channel_id>", "channel.<channel_id>.sub.topic.x", ...]).
# If you want to listen on all subjects, just pass one element ["channels.>"], otherwise
# pass the list of subjects (e.g ["channels.<channel_id>", "channels.<channel_id>.sub.topic.x", ...]).
[subjects]
filter = ["channel.>"]
filter = ["channels.>"]