Skip to content

Commit

Permalink
Merge pull request #97 from ably-forks/feature/add-metadata-streaminf…
Browse files Browse the repository at this point in the history
…o-name-subject

Metadata: add missing getters for the stream name and subject
  • Loading branch information
tylertreat authored Nov 19, 2020
2 parents b849ccc + 1bfa7de commit c842e2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion v2/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ func TestFetchMetadata(t *testing.T) {
}},
Metadata: []*proto.StreamMetadata{{
Name: "foo",
Subject: "foo",
Subject: "foo-subject",
Partitions: map[int32]*proto.PartitionMetadata{
0: {
Id: 0,
Expand Down Expand Up @@ -1304,6 +1304,8 @@ func TestFetchMetadata(t *testing.T) {

stream := metadata.GetStream("foo")
require.NotNil(t, stream)
require.Equal(t, "foo-subject", stream.Subject())
require.Equal(t, "foo", stream.Name())
require.Len(t, stream.Partitions(), 1)
partition := stream.GetPartition(0)
require.NotNil(t, partition)
Expand Down
10 changes: 10 additions & 0 deletions v2/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ type StreamInfo struct {
creationTime time.Time
}

// Subject returns the stream's subject.
func (s *StreamInfo) Subject() string {
return s.subject
}

// Name returns the stream's name.
func (s *StreamInfo) Name() string {
return s.name
}

// GetPartition returns the partition info for the given partition id or nil if
// no such partition exists.
func (s *StreamInfo) GetPartition(id int32) *PartitionInfo {
Expand Down

0 comments on commit c842e2f

Please sign in to comment.