Skip to content

Commit

Permalink
Add Stream.IsCompressed utility function
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Sep 19, 2023
1 parent c609acc commit 0465936
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ func (s *Stream) IsMQTTState() bool {
return IsMQTTStateStream(s.Name())
}

// IsCompressed determines if a stream is compressed
func (s *Stream) IsCompressed() bool {
return s.Compression() != api.NoCompression
}

// ContainedSubjects queries the stream for the subjects it holds with optional filter
func (s *Stream) ContainedSubjects(filter ...string) (map[string]uint64, error) {
return s.mgr.StreamContainedSubjects(s.Name(), filter...)
Expand Down
19 changes: 19 additions & 0 deletions streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,25 @@ func TestStream_ContainedSubjects(t *testing.T) {
// }
}

func TestStream_Compression(t *testing.T) {
srv, nc, mgr := startJSServer(t)
defer srv.Shutdown()
defer nc.Flush()

s, err := mgr.NewStream("f1", jsm.Subjects("test.*"), jsm.FileStorage(), jsm.Compression(api.S2Compression))
checkErr(t, err, "create failed")

nfo, err := s.Information()
checkErr(t, err, "info failed")

if nfo.Config.Compression != api.S2Compression {
t.Fatalf("s2 compression was not set")
}

if !s.IsCompressed() {
t.Fatalf("s2 compression was not reported correctly")
}
}
func TestStream_DetectGaps(t *testing.T) {
srv, nc, mgr := startJSServer(t)
defer srv.Shutdown()
Expand Down

0 comments on commit 0465936

Please sign in to comment.