nats-io / jsm.go

JetStream Management Library for Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing DeliverNew, DeliverLast, DeliverNext methods

syacko opened this issue · comments

DeliverAllAvailable() exists for the creation of a consumer. There are no functions for DeliverPolicy of new, last or next.

func DeliverAllAvailable() ConsumerOption {
	return func(o *ConsumerCfg) error {
		resetDeliverPolicy(o)
		o.ConsumerConfig.DeliverPolicy = api.DeliverAll
		return nil
	}
}

Recommended:

func DeliverNextAvailable() ConsumerOption {
	return func(o *ConsumerCfg) error {
		resetDeliverPolicy(o)
		o.ConsumerConfig.DeliverPolicy = api.DeliverNext
		return nil
	}
}
func DeliverNew() ConsumerOption {
	return func(o *ConsumerCfg) error {
		resetDeliverPolicy(o)
		o.ConsumerConfig.DeliverPolicy = api.DeliverNew
		return nil
	}
}
func DeliverLast() ConsumerOption {
	return func(o *ConsumerCfg) error {
		resetDeliverPolicy(o)
		o.ConsumerConfig.DeliverPolicy = api.DeliverLast
		return nil
	}
}

StartWithLastReceived(), StartWithNextReceived()

There is no DeliverNew only DeliverNext

Not the best names I bet but I mimicked streaming server clients for these

Ok, this looks like it works. Thank you for the quick reply.