From 2854d5a0615bdb319de18a6f20704c79235c51f2 Mon Sep 17 00:00:00 2001 From: doluca Date: Sun, 2 May 2021 03:27:52 +0300 Subject: [PATCH] publish: message headers added --- publish.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/publish.go b/publish.go index 1733b6c..dc2c77b 100644 --- a/publish.go +++ b/publish.go @@ -40,6 +40,7 @@ type PublishOptions struct { ContentType string // Transient or Persistent DeliveryMode uint8 + Headers Table } // WithPublishOptionsExchange returns a function that sets the exchange to publish to @@ -76,6 +77,13 @@ func WithPublishOptionsPersistentDelivery(options *PublishOptions) { options.DeliveryMode = Persistent } +// WithPublishOptionsHeaders returns a function that sets message header values, i.e. "msg-id" +func WithPublishOptionsHeaders(headers Table) func(*PublishOptions) { + return func(options *PublishOptions) { + options.Headers = headers + } +} + // Publisher allows you to publish messages safely across an open connection type Publisher struct { chManager *channelManager @@ -182,6 +190,7 @@ func (publisher *Publisher) Publish( options.Mandatory, options.Immediate, amqp.Publishing{ + Headers: tableToAMQPTable(options.Headers), ContentType: options.ContentType, Body: data, DeliveryMode: options.DeliveryMode,