Skip to content

Commit

Permalink
Merge pull request nats-io#1080 from roeschter/sub-pull-durable-docs2
Browse files Browse the repository at this point in the history
Squashed commit of the following:
  • Loading branch information
ripienaar authored Jun 20, 2024
2 parents 3a7c770 + e3202d8 commit e2e635c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cli/sub_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,26 @@ type subCmd struct {

func configureSubCommand(app commandHost) {
c := &subCmd{}

subHelp := `
Jetstream will be activated when related options like --stream, --durabled or --ack are supplied.
E.g. nats sub <subject that is bound to a stream> --all
Currently only supports push subscriptions. Uses an ephemeral consumer without ack by default.
For specific consumer options please pre-create a consumer using 'nats consumer add'.app.
E.g. when explicit acknowledgement is required.
Caution: Be careful when subscribing to streams with WorkQueue policy. Messages will be acked and deleted when a durable consumer is being used.
Use nats stream view <stream> for inspecting messages.
`

act := app.Command("subscribe", "Generic subscription client").Alias("sub").Action(c.subscribe)
act.HelpLong(subHelp)
addCheat("sub", act)

act.Arg("subjects", "Subjects to subscribe to").StringsVar(&c.subjects)
Expand All @@ -73,6 +92,10 @@ func configureSubCommand(app commandHost) {
act.Flag("raw", "Show the raw data received").Short('r').UnNegatableBoolVar(&c.raw)
act.Flag("translate", "Translate the message data by running it through the given command before output").StringVar(&c.translate)
act.Flag("ack", "Acknowledge JetStream message that have the correct metadata").BoolVar(&c.jsAck)
// We do not support (explicit) ackPolicy right now. The only situation where it is useful would be WorkQueue policy right now.
// Deleting from a stream with WorkQueue through ack could be unexpected behavior in the sub command.
// To be done - check for streams with WorkQueue, then prompt with or allow with override --force=WorkQueueDelete
// act.Flag("ackPolicy", "Acknowledgment policy (none, all, explicit) (requires JetStream)").Default("none").EnumVar(&c.ackPolicy, "none", "all", "explicit")
act.Flag("match-replies", "Match replies to requests").UnNegatableBoolVar(&c.match)
act.Flag("inbox", "Subscribes to a generate inbox").Short('i').UnNegatableBoolVar(&c.inbox)
act.Flag("count", "Quit after receiving this many messages").UintVar(&c.limit)
Expand Down

0 comments on commit e2e635c

Please sign in to comment.