fogfish / esq

simple persistent queues for Erlang
Apache License 2.0
56 stars 8 forks source link

Validate queue options and exit if option is not acceptable #5

Open silviucpp opened 7 years ago

silviucpp commented 7 years ago

Hello,

Having the following queue:

{ok, Q}= esq:new( "priv/client_producer", [{tts, 0}, {capacity, 0}]).

After I add few items inside the queue and restart the app and do:

esq:head(Q).

I always receive undefined but esq:deq always returns items. I'm expecting head to return same stuff as deq but without removing the item from queue.

I'm using [{tts, 0}, {capacity, 0}] to make sure all items are going on the disk directly. I'm wrong ?

Silviu

fogfish commented 7 years ago

I'll check it... but please keep in mind that tts is queue time-to-sync (rotate) file segments in milliseconds. I would not keep it equal to 0.

silviucpp commented 7 years ago

ohh ok :) thanks

fogfish commented 7 years ago

Right, I've checked your case deeply. Actually, 0 is not valid value for tts and capacity. The capacity defines the size of in-memory queue. The queue would not fetch anything from disk into memory buffer if capacity is 0. You should not afraid to put capacity > 0. The queue always writes data to disk during enqueue.

fogfish commented 7 years ago

I would do the following improvements

silviucpp commented 7 years ago

@fogfish you can also add documentation for capacity in the readme