Documentation ¶
Index ¶
Constants ¶
View Source
const ( KiB = 8 * 1024 MiB = KiB * 1024 GiB = MiB * 1024 )
View Source
const (
StreamDefaultMaxAge = time.Hour * 48
)
Variables ¶
View Source
var ( ConsumerMetrics = promauto.NewHistogramVec( prometheus.HistogramOpts{ Namespace: "nats", Subsystem: "consumer", Name: "duration_consume", Help: "Consume duration", Buckets: []float64{.005, .01, .025, .05, .075, .1, .15, .2, .25, .5, 1, 2.5, 5, 10, 15, 30}, }, []string{"subject", "action", "error"}, ) PublisherMetrics = promauto.NewHistogramVec( prometheus.HistogramOpts{ Namespace: "nats", Subsystem: "publisher", Name: "duration_publish", Help: "Publish duration", Buckets: []float64{.005, .01, .025, .05, .075, .1, .15, .2, .25, .5, 1, 2.5, 5, 10, 15, 30}, }, []string{"subject", "error"}, ) )
View Source
var ( ErrSubjectRequired = errors.New("subject is required") ErrInvalidChars = errors.New("subject contains spaces") )
View Source
var ErrGroupRequired = errors.New("group is required")
Functions ¶
func CollectConsumerMetric ¶
func CollectPublisherMetrics ¶
Types ¶
type Consumer ¶
type Consumer[T any] struct { // contains filtered or unexported fields }
func NewConsumer ¶
func NewConsumer[T any](ctx context.Context, conn *nats.Conn, group, subject string, h events.Handler[T], opts ...ConsumerOpt) (*Consumer[T], error)
NewConsumer creates nats QueueSubscribe with custom handler Group must be the name of service or package: core, feed, etc. It's allow handle messages in few consumers.
type ConsumerOpt ¶
type ConsumerOpt func(*nats.ConsumerConfig)
func WithAckPolicy ¶
func WithAckPolicy(policy nats.AckPolicy) ConsumerOpt
func WithAckWait ¶
func WithAckWait(wait time.Duration) ConsumerOpt
func WithDeliverPolicy ¶
func WithDeliverPolicy(policy nats.DeliverPolicy) ConsumerOpt
func WithMaxAckPending ¶
func WithMaxAckPending(count int) ConsumerOpt
func WithRateLimit ¶
func WithRateLimit(limit uint64) ConsumerOpt
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
func NewProducer ¶
NewProducer ... fixme: add description
func (*Producer) PublishData ¶
Click to show internal directories.
Click to hide internal directories.