Skip to content

Commit

Permalink
feat: add client.PublishOption for setting message delivery mode
Browse files Browse the repository at this point in the history
  • Loading branch information
quexer committed Oct 22, 2023
1 parent bc05fb0 commit 09bc84c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions v4/broker/rabbitmq/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"go-micro.dev/v4/broker"
"go-micro.dev/v4/client"
)

type durableQueueKey struct{}
Expand Down Expand Up @@ -164,3 +165,14 @@ type ackSuccessKey struct{}
func AckOnSuccess() broker.SubscribeOption {
return setSubscribeOption(ackSuccessKey{}, true)
}

// PublishDeliveryMode client.PublishOption for setting message "delivery mode"
// mode , Transient (0 or 1) or Persistent (2)
func PublishDeliveryMode(mode uint8) client.PublishOption {
return func(o *client.PublishOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, deliveryMode{}, mode)
}
}

0 comments on commit 09bc84c

Please sign in to comment.