mcollina / mqemitter-mongodb

MongoDB based MQEmitter
MIT License
18 stars 10 forks source link

convertToCapped to be optional #6

Closed muz3 closed 6 years ago

muz3 commented 6 years ago

Hi Matt,

Can you please let me know why we are forcing the convertToCapped here? I know it provide you certain level of benefit over performance, but in some cases, I would like to have it be uncapped. Is there a way to achieve right now?

thanks,

Rui ` function waitStartup () { that._collection = that._db.collection(opts.collection) that._collection.isCapped(function (err, capped) { if (that.closed) { return }

  if (err) {
    // if it errs here, the collection might not exist
    that._db.createCollection(opts.collection, {
      capped: true,
      size: opts.size,
      max: opts.max
    }, start)
  } else if (!capped) {
    // the collection is not capped, make it so
    that._db.command({
      convertToCapped: opts.collection,
      size: opts.size,
      max: opts.max
    }, start)
  } else {
    start()
  }
})

}`

mcollina commented 6 years ago

That collection is internal and should not be used. Why would you like it to be uncapped?

muz3 commented 6 years ago

Thanks for your reply. I might it used it incorrectly of this library. I am trying to store all incoming messages for a particular topic, then later I can replay all them. I can overwrite collection, size and max, but just want to see if there is option to uncap. Looks like this library is used as buffering for 'LAST Retained' purpose in 'aedes-persistence-mongodb'.

mcollina commented 6 years ago

I do not think you are using this correctly.