Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

pkg/types/path Distinguish between /topicA and /topicA/ #430

Merged
merged 3 commits into from
Mar 15, 2017

Conversation

YujiOshima
Copy link
Contributor

@chungers In #429, behavior seems to be different from what we were discussing.
It can not distinguish between topic /A and topic /A/.
Therefore, subscribing /toppicA will always subscribe all of /topicA/ and below subtopic, you can not subscribe only /topicA.
I added test TestBrokerSubscriberExactMatchTopic. This is the test I want to do in this PR.

Signed-off-by: Yuji Oshima [email protected]

Signed-off-by: Yuji Oshima <[email protected]>
@codecov
Copy link

codecov bot commented Mar 13, 2017

Codecov Report

Merging #430 into master will decrease coverage by 0.06%.
The diff coverage is 73.68%.

@@            Coverage Diff             @@
##           master     #430      +/-   ##
==========================================
- Coverage   62.49%   62.42%   -0.07%     
==========================================
  Files          73       73              
  Lines        4495     4506      +11     
==========================================
+ Hits         2809     2813       +4     
- Misses       1356     1359       +3     
- Partials      330      334       +4
Impacted Files Coverage Δ
pkg/types/path.go 77.45% <100%> (+1.66%)
pkg/broker/server/sse.go 73.1% <58.33%> (-0.81%)
pkg/manager/group_plugin_impl.go 14.89% <0%> (-4.26%)
pkg/manager/manager.go 63.63% <0%> (-2.43%)
pkg/plugin/group/group.go 68.29% <0%> (-0.82%)
pkg/types/reflect.go 72.09% <0%> (+1.55%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c50cb20...045f7c8. Read the comment docs.

for ch := range chset {
for ch, value := range chset {
if value.exactMatch && event.topic != key {
fmt.Printf("skip notifier event.topic%v, key %v\n", event.topic, key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove this?

fmt.Printf("skip notifier event.topic%v, key %v\n", event.topic, key)
return false
}
fmt.Printf("notifier event.topic%v, key %v\n", event.topic, key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Can you remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry! I removed.

@@ -80,6 +87,13 @@ func clean(topic string) string {
return topic
}

func checkExactMatch(topic string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be written as one line right?

Copy link
Contributor Author

@YujiOshima YujiOshima Mar 14, 2017

Choose a reason for hiding this comment

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

Thanks! fixed.

@@ -167,7 +181,7 @@ func (b *Broker) run() {
// Disconnect all clients
b.clients.Walk(
func(key string, value interface{}) bool {
chset, ok := value.(map[chan []byte]int)
chset, ok := value.(map[chan []byte]clientValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we just have a simpler value in the radix tree without the type clientValue?

We really just need something like map[chan[]byte]bool, where the value bool is exactMatch or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote this because I was not sure how to use the original int. Fixed, thanks!

}

type event struct {
topic string
data []byte
}

type clientValue struct {
value int
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't need this struct type at all. We only need to store the value in the radix tree as map[chan []byte]bool where bool is just the exactMatch value. We don't need this value field...

Signed-off-by: Yuji Oshima <[email protected]>
Copy link
Contributor

@chungers chungers left a comment

Choose a reason for hiding this comment

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

Thanks!!

@chungers chungers merged commit 6c0d4ff into docker-archive:master Mar 15, 2017
chungers pushed a commit to chungers/infrakit that referenced this pull request Sep 30, 2017
Display NAT rules for SSH LB in output for ARM
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants