Skip to content

Commit

Permalink
Merge pull request #1107 from nats-io/fix_1106
Browse files Browse the repository at this point in the history
[FIXED] Display all configured channels
  • Loading branch information
kozlovic authored Oct 13, 2020
2 parents 6bb225a + 43b9f83 commit f989c51
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ func getTestDefaultOptsForPersistentStore() *Options {
case stores.TypeFile:
opts.FilestoreDir = defaultDataStore
opts.FileStoreOpts.BufferSize = 1024
// Go 1.12 on macOS is very slow at doing sync writes...
if runtime.GOOS == "darwin" && strings.HasPrefix(runtime.Version(), "go1.12") {
// Since Go 1.12, on macOS it is very slow to do sync writes...
if runtime.GOOS == "darwin" {
opts.FileStoreOpts.DoSync = false
}
case stores.TypeSQL:
Expand Down
9 changes: 7 additions & 2 deletions util/sublist.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ func (s *Sublist) Subjects() []string {

func getSubjects(l *level, subject string, res *[]string) {
if l == nil || l.numNodes() == 0 {
*res = append(*res, subject)
return
}
var fs string
Expand All @@ -500,14 +499,17 @@ func getSubjects(l *level, subject string, res *[]string) {
} else {
fs = sfwc
}
getSubjects(l.fwc.next, fs, res)
*res = append(*res, fs)
}
if l.pwc != nil {
if subject != "" {
fs = subject + tsep + spwc
} else {
fs = spwc
}
if len(l.pwc.elements) > 0 {
*res = append(*res, fs)
}
getSubjects(l.pwc.next, fs, res)
}
for s, n := range l.nodes {
Expand All @@ -516,6 +518,9 @@ func getSubjects(l *level, subject string, res *[]string) {
} else {
fs = s
}
if len(n.elements) > 0 {
*res = append(*res, fs)
}
getSubjects(n.next, fs, res)
}
}
29 changes: 29 additions & 0 deletions util/sublist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,33 @@ func TestSublistSubjects(t *testing.T) {
t.Fatalf("Result expected to be either %v or %v, got %v", pOne, pTwo, r)
}
}

subjects = []string{"bar", "bar.*", "bar.baz", "bar.>", "bar.*.bat", "bar.baz.*", "bar.baz.biz.box", "bar.baz.>"}
expected := []string{"bar", "bar.>", "bar.*", "bar.*.bat", "bar.baz", "bar.baz.>", "bar.baz.*", "bar.baz.biz.box"}
s := NewSublist()
for _, subj := range subjects {
s.Insert(subj, subj)
}
r := s.Match("bar")
if len(r) == 0 {
t.Fatalf("bar should be in the sublist")
}
if r[0].(string) != "bar" {
t.Fatalf("invalid value for bar: %q", r[0].(string))
}
subjs := s.Subjects()
if !reflect.DeepEqual(subjs, expected) {
t.Fatalf("Expected subject:\n%q\n got\n%q", expected, subjs)
}

subjects = []string{"bar", "bar.*.*.box", "bar.baz.bat.*", ">", "*", "bar.baz.bat"}
expected = []string{">", "*", "bar", "bar.*.*.box", "bar.baz.bat", "bar.baz.bat.*"}
s = NewSublist()
for _, subj := range subjects {
s.Insert(subj, subj)
}
subjs = s.Subjects()
if !reflect.DeepEqual(subjs, expected) {
t.Fatalf("Expected subject:\n%q\n got\n%q", expected, subjs)
}
}

0 comments on commit f989c51

Please sign in to comment.