From 8325c1caf632505f73dbdabd993f4742e10cb407 Mon Sep 17 00:00:00 2001 From: Manuel Imperiale Date: Mon, 6 Apr 2020 12:30:26 +0200 Subject: [PATCH] MF-1091 - Use channels. as broker prefix (#1098) Signed-off-by: Manuel Imperiale --- broker/nats.go | 13 +++++++------ docker/addons/cassandra-writer/subjects.toml | 6 +++--- docker/addons/influxdb-writer/subjects.toml | 6 +++--- docker/addons/mongodb-writer/subjects.toml | 6 +++--- docker/addons/postgres-writer/subjects.toml | 6 +++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/broker/nats.go b/broker/nats.go index 89da99d1..fdc2689b 100644 --- a/broker/nats.go +++ b/broker/nats.go @@ -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.>" ) var ( @@ -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) } @@ -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) } diff --git a/docker/addons/cassandra-writer/subjects.toml b/docker/addons/cassandra-writer/subjects.toml index 16c3695a..27361eee 100644 --- a/docker/addons/cassandra-writer/subjects.toml +++ b/docker/addons/cassandra-writer/subjects.toml @@ -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..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.", "channels..sub.topic.x", ...]). [subjects] -filter = ["channel.>"] +filter = ["channels.>"] diff --git a/docker/addons/influxdb-writer/subjects.toml b/docker/addons/influxdb-writer/subjects.toml index 16c3695a..27361eee 100644 --- a/docker/addons/influxdb-writer/subjects.toml +++ b/docker/addons/influxdb-writer/subjects.toml @@ -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..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.", "channels..sub.topic.x", ...]). [subjects] -filter = ["channel.>"] +filter = ["channels.>"] diff --git a/docker/addons/mongodb-writer/subjects.toml b/docker/addons/mongodb-writer/subjects.toml index 16c3695a..27361eee 100644 --- a/docker/addons/mongodb-writer/subjects.toml +++ b/docker/addons/mongodb-writer/subjects.toml @@ -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..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.", "channels..sub.topic.x", ...]). [subjects] -filter = ["channel.>"] +filter = ["channels.>"] diff --git a/docker/addons/postgres-writer/subjects.toml b/docker/addons/postgres-writer/subjects.toml index 16c3695a..27361eee 100644 --- a/docker/addons/postgres-writer/subjects.toml +++ b/docker/addons/postgres-writer/subjects.toml @@ -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..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.", "channels..sub.topic.x", ...]). [subjects] -filter = ["channel.>"] +filter = ["channels.>"]