adjust / rmq

Message queue system written in Go and backed by Redis
MIT License
1.57k stars 206 forks source link

There isn't support to set and get headers in delivery interface #160

Closed purush7 closed 11 months ago

purush7 commented 11 months ago
type Delivery interface {
    Payload() string

    Ack() error
    Reject() error
    Push() error
}

var (
    _ Delivery   = &redisDelivery{}
    _ WithHeader = &redisDelivery{}
)

type redisDelivery struct {
    ctx          context.Context
    payload      string
    clearPayload string
    header       http.Header
    unackedKey   string
    rejectedKey  string
    pushKey      string
    redisClient  RedisClient
    errChan      chan<- error
}

func (delivery *redisDelivery) Header() http.Header {
    return delivery.header
}

func (delivery *redisDelivery) String() string {
    return fmt.Sprintf("[%s %s]", delivery.clearPayload, delivery.unackedKey)
}

func (delivery *redisDelivery) Payload() string {
    return delivery.clearPayload
}

in delivery.go

Why don't we have get and set headers support in delivery? UseCase: We want to have a type of message in header. It also can be in payload but to get the type we need to do unmarshal it as payload will be in bytes.

I wanted to know the reasoning behind why the set and get for headers isn't present

wellle commented 11 months ago

Please see the example in the readme of how to set and get headers: https://github.com/adjust/rmq#header

purush7 commented 11 months ago

@wellle Thanks for the quick reply