Open thothothotho opened 3 years ago
Other possibilities. To enforce that some parameters are mandatory
r.channel.QueueDeclare("foo", amqp.AutoDelete)
where
type Option func(interface{})
var AutoDelete Option = func(v interface{}) {
opts := v.(*queueDeclare)
opts.AutoDelete = true
}
func (ch *Channel) QueueDeclare(queue string, options Option...) {
var cmd = queueDeclare{Queue: queue}
applyOptions(&cmd, options) // some helper
...
}
That kind of code:
is quite difficult to read. Maybe rabbitmq specialists have no problem parsing this, but I have. And so my colleagues reviewing my code. So I'm writing this:
I really wish I could write that:
more example
So, maybe you should expose your implementation as public stuff. Internally, you're doing exactly that:
ch.call(someType)
is really the best readable API, please expose it, it's brilliant.Thanks