Updates based on feedback

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2020-06-26 10:29:53 -07:00
parent 6c805eebc7
commit 920617d64a
3 changed files with 8 additions and 10 deletions

View File

@@ -489,15 +489,7 @@ func (a *Account) TotalSubs() int {
// for the given `subject`. Works only for literal subjects.
// TODO: Add support for wildcards
func (a *Account) SubscriptionInterest(subject string) bool {
var interest bool
a.mu.RLock()
if a.sl != nil {
if res := a.sl.Match(subject); len(res.psubs)+len(res.qsubs) > 0 {
interest = true
}
}
a.mu.RUnlock()
return interest
return a.Interest(subject) > 0
}
// Interest returns the number of subscriptions for a given subject that match.

View File

@@ -1639,6 +1639,7 @@ func TestLeafNodeOriginClusterInfo(t *testing.T) {
// Make sure we disconnect and reconnect.
checkLeafNodeConnectedCount(t, s, 0)
checkLeafNodeConnected(t, s)
checkLeafNodeConnected(t, hub)
l = grabLeaf()
if rc := l.remoteCluster(); rc != "xyz" {

View File

@@ -3986,7 +3986,7 @@ func TestLeafNodeOriginCluster(t *testing.T) {
defer nc3.Close()
wcSubj := "foo.*"
nc3.SubscribeSync(wcSubj)
wcsub, _ := nc3.SubscribeSync(wcSubj)
// This is a placeholder that we can use to check all interest has propagated.
nc3.SubscribeSync("bar")
waitForInterest("bar", ln1, ln2, ln3, ca.servers[0], ca.servers[1], ca.servers[2])
@@ -4006,6 +4006,11 @@ func TestLeafNodeOriginCluster(t *testing.T) {
if n, _, _ := sub.Pending(); n != 1 {
t.Fatalf("Expected only one message, got %d", n)
}
// Also for wc
if n, _, _ := wcsub.Pending(); n != 1 {
t.Fatalf("Expected only one message, got %d", n)
}
// grab the msg
msg, _ := sub.NextMsg(time.Second)
if !bytes.Equal(m.Data, msg.Data) {