Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Stream and Consumer management APIs #626

Merged
merged 2 commits into from
Jan 13, 2021
Merged

Conversation

variadico
Copy link
Contributor

@variadico variadico commented Dec 16, 2020

This adds the follow APIs for Streams.

  • UpdateStream
  • DeleteStream
  • SnapshotStream
  • RestoreStream
  • PurgeStream
  • StreamLister

This adds the follow APIs for Consumers.

  • ConsumerInfo
  • ConsumerLister
  • DeleteConsumer

@variadico variadico force-pushed the add-management branch 2 times, most recently from 7910891 to 939afd1 Compare December 16, 2020 23:59
@coveralls
Copy link

coveralls commented Dec 17, 2020

Coverage Status

Coverage decreased (-0.8%) to 86.901% when pulling 3e0aed6 on add-management into b4450fb on master.

js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated
Consumers []*ConsumerInfo `json:"consumers"`
}

func (js *js) ListConsumers(stream string, offset int) ([]*ConsumerInfo, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Be good if we could hide the paging at this layer or undo it below the covers and just make it a stream of messages with EOF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All right. I added a StreamLister and ConsumerLister to iterate through pages.

This is what the calling code looks like.

sl := js.NewStreamLister()
for sl.Next() {
	// sl.Page() returns a []*StreamInfo.
	// Each iteration can return a maximum of 256 items.
	fmt.Println(sl.Page())
}
if err := sl.Err(); err != nil {
	return err
}

Here's what it looks like in tests.
https://github.com/nats-io/nats.go/pull/626/files#diff-9e6bdee4051a6e36d6d507dcef63b5f9a39b281e421c08f02ec74a0fb6639e3aR592-R626

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

Some little changes needed I believe.

js.go Outdated Show resolved Hide resolved
js.go Show resolved Hide resolved
js.go Show resolved Hide resolved
js.go Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
js.go Show resolved Hide resolved
@variadico variadico force-pushed the add-management branch 2 times, most recently from f8b6286 to 544e9c4 Compare January 4, 2021 22:03
@variadico
Copy link
Contributor Author

Okay, @kozlovic. I think I resolved all of the comments you had. Thanks for the review. 👍

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

I would be ok with the change, but I have asked other to chime in with regards to the addition of the timeout in the stream snapshot config struct.

js.go Outdated Show resolved Hide resolved
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

Check snapshot config for nil and deliver subject.

js.go Outdated Show resolved Hide resolved
js.go Outdated Show resolved Hide resolved
This adds the follow APIs for Streams.
* UpdateStream
* DeleteStream
* SnapshotStream
* RestoreStream
* PurgeStream
* StreamLister

This adds the follow APIs for Consumers.
* ConsumerInfo
* ConsumerLister
* DeleteConsumer
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

LGTM

@kozlovic
Copy link
Member

kozlovic commented Jan 6, 2021

@variadico Not sure why you removed snapshot? I think @ripienaar comment was about Timeout in config, but I may be wrong. Clearly, we can always add features later, so I don't have a problem removing, just curious as to why you remove it.

@variadico
Copy link
Contributor Author

@wallyqs wanted some more time to think about the snapshotting logic, so I removed that from this PR. That'll be added later. Additionally, he's going to add a few more management APIs.

@derekcollison
Copy link
Member

We should have DeleteMsg and EraseMsg for the Stream Management API..

Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

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

LGTM, also adding DeleteMsg as a different PR here: Adding DeleteMsg as a separate PR here #631

@wallyqs wallyqs merged commit be60b83 into master Jan 13, 2021
@wallyqs wallyqs deleted the add-management branch January 13, 2021 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants