JohanObrink / fluent-amqp

Fluent syntax for amqp (Rabbit MQ) with (highland) streaming messages and automatic reconnect.
MIT License
3 stars 2 forks source link

Pipeline support #1

Open irony opened 7 years ago

irony commented 7 years ago

If I have a highland stream, I would like instead of this code:

trips.fork().each(trip => {
  amqp(rabbitURL)
    .queue('trip', {durable: true})
    .publish(trip, {persistent: true})
    .then(() => console.log(` [x] Sent trip '${trip.id}'`))
})

To be able to write something like this:

const queue = amqp(url).queue('trip', {durable:true})
trips.pipe(queue)

Would that be possible?

JohanObrink commented 7 years ago

The way I would write it now is this:

const queue = amqp(url).queue('trip', {durable:true})
trips.fork().each(trip => queue.publish(trip, {persistent: true}))

I'll have a look at pipe and see how I'd get your suggestion to work.