From 0e1f744fcc438c1ee633e7013c99429e537b694e Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 10 Oct 2020 00:47:09 +0300 Subject: [PATCH] add helper for publish options Signed-off-by: Vasiliy Tolstov --- broker/options.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/broker/options.go b/broker/options.go index 974b9d1e..9542c59f 100644 --- a/broker/options.go +++ b/broker/options.go @@ -45,6 +45,18 @@ type PublishOptions struct { Context context.Context } +func NewPublishOptions(opts ...PublishOption) PublishOptions { + opt := PublishOptions{ + Context: context.Background(), + } + + for _, o := range opts { + o(&opt) + } + + return opt +} + type SubscribeOptions struct { // AutoAck ack messages if handler returns nil err AutoAck bool