@@ -75,8 +75,8 @@ func SubscriberErrorLogger(logger log.Logger) SubscriberOption {
7575
7676// ServeDelivery handles AMQP Delivery messages
7777// It is strongly recommended to use *amqp.Channel as the
78- // AMQPChannel interface implementation
79- func (s Subscriber ) ServeDelivery (ch AMQPChannel ) func (deliv * amqp.Delivery ) {
78+ // Channel interface implementation
79+ func (s Subscriber ) ServeDelivery (ch Channel ) func (deliv * amqp.Delivery ) {
8080 return func (deliv * amqp.Delivery ) {
8181 ctx , cancel := context .WithCancel (context .Background ())
8282 defer cancel ()
@@ -122,7 +122,7 @@ func (s Subscriber) ServeDelivery(ch AMQPChannel) func(deliv *amqp.Delivery) {
122122func EncodeJSONResponse (
123123 ctx context.Context ,
124124 deliv * amqp.Delivery ,
125- ch AMQPChannel ,
125+ ch Channel ,
126126 pub * amqp.Publishing ,
127127 response interface {},
128128) error {
@@ -155,7 +155,7 @@ func EncodeJSONResponse(
155155func EncodeNopResponse (
156156 ctx context.Context ,
157157 deliv * amqp.Delivery ,
158- ch AMQPChannel ,
158+ ch Channel ,
159159 pub * amqp.Publishing ,
160160 response interface {},
161161) error {
@@ -167,32 +167,30 @@ func EncodeNopResponse(
167167// their replies, and will likely want to pass and check for their own error
168168// types.
169169type ErrorEncoder func (ctx context.Context ,
170- err error , deliv * amqp.Delivery , ch AMQPChannel , pub * amqp.Publishing )
170+ err error , deliv * amqp.Delivery , ch Channel , pub * amqp.Publishing )
171171
172172// DefaultErrorEncoder simply ignores the message. It does not reply
173173// nor Ack/Nack the message.
174174func DefaultErrorEncoder (ctx context.Context ,
175- err error , deliv * amqp.Delivery , ch AMQPChannel , pub * amqp.Publishing ) {
176- return
175+ err error , deliv * amqp.Delivery , ch Channel , pub * amqp.Publishing ) {
177176}
178177
179- // NackErrorEncoder issues a Nack to the delivery with multiple flag set as false
178+ // SingleNackRequeueErrorEncoder issues a Nack to the delivery with multiple flag set as false
180179// and requeue flag set as true. It does not reply the message.
181180func SingleNackRequeueErrorEncoder (ctx context.Context ,
182- err error , deliv * amqp.Delivery , ch AMQPChannel , pub * amqp.Publishing ) {
181+ err error , deliv * amqp.Delivery , ch Channel , pub * amqp.Publishing ) {
183182 deliv .Nack (
184183 false , //multiple
185184 true , //requeue
186185 )
187186 duration := getNackSleepDuration (ctx )
188187 time .Sleep (duration )
189- return
190188}
191189
192190// ReplyErrorEncoder serializes the error message as a DefaultErrorResponse
193191// JSON and sends the message to the ReplyTo address
194192func ReplyErrorEncoder (ctx context.Context ,
195- err error , deliv * amqp.Delivery , ch AMQPChannel , pub * amqp.Publishing ) {
193+ err error , deliv * amqp.Delivery , ch Channel , pub * amqp.Publishing ) {
196194
197195 if pub .CorrelationId == "" {
198196 pub .CorrelationId = deliv .CorrelationId
@@ -221,21 +219,23 @@ func ReplyErrorEncoder(ctx context.Context,
221219 )
222220}
223221
224- // ReplyErrorEncoder serializes the error message as a DefaultErrorResponse
222+ // ReplyAndAckErrorEncoder serializes the error message as a DefaultErrorResponse
225223// JSON and sends the message to the ReplyTo address then Acks the original
226224// message
227- func ReplyAndAckErrorEncoder (ctx context.Context , err error , deliv * amqp.Delivery , ch AMQPChannel , pub * amqp.Publishing ) {
225+ func ReplyAndAckErrorEncoder (ctx context.Context , err error , deliv * amqp.Delivery , ch Channel , pub * amqp.Publishing ) {
228226 ReplyErrorEncoder (ctx , err , deliv , ch , pub )
229227 deliv .Ack (false )
230228}
231229
230+ // DefaultErrorResponse is the default structure of responses in the event
231+ // of an error
232232type DefaultErrorResponse struct {
233233 Error string `json:"err"`
234234}
235235
236- // Channel interface to make testing possible
236+ // Channel is a channel interface to make testing possible
237237// It is highly recommended to use *amqp.Channel as the interface implementation
238- type AMQPChannel interface {
238+ type Channel interface {
239239 Publish (exchange , key string , mandatory , immediate bool , msg amqp.Publishing ) error
240240 Consume (queue , consumer string , autoAck , exclusive , noLocal , noWail bool , args amqp.Table ) (<- chan amqp.Delivery , error )
241241}
0 commit comments