Seppuku

Track error occurrences and shutdown service instance once a defined number of unique messages have errors in a defined time period.
great point


- shane

On Thu, Oct 16, 2014 at 3:01 PM, Dan Matthews <notifications@github.com>
wrote:

> In lib/emque/consuming/error_tracker.rb:
>
> > +        occurances[key_for(context)] = Time.now + expiration
> > +      end
> > +
> > +      def limit_reached?
> > +        recent_errors.keys.count >= limit
> > +      end
> > +
> > +      private
> > +
> > +      attr_accessor :occurances
> > +      attr_writer :limit, :expiration
> > +
> > +      def recent_errors
> > +        occurances.delete_if do |key, expiration_time|
> > +          expiration_time < Time.now
> > +        end
>
> I decided to care about uniqueness because I didn't want the potential of
> a single bad message, placed into the queue multiple times for whatever
> reason to cause a shutdown. My first pass used a set, but this seemed like
> the best compromise given the functionality constraints, specifically the
> timed expiration of unique messages. I also am not terribly worried about
> the speed, since the max size of this thing is equivalent to the value of
> limit.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/teamsnap/emque-consuming/pull/11/files#r18978133>.
>