BrightcoveOS/Diamond — pull request #141 by phobos182 (2012-09-06 22:38:44+00:00)
Title: Added handler flush() functionality

Use Case:
When batching requests to save on RPC calls to a remote system, the pattern used is to append metrics to an array. Once the array meets the batch size, send the request. Issues arise when the collector script terminates there may be items still in the array that have not been sent because they have not reached the batch size.

To resolve this, I have added a finally method to the collector run to invoke 'flush()' on each handler once a collector script has finished it's run. I have also added a default 'flush()' method on the Handler base class that can be overridden by the subclasses. Therefore handlers can choose to use the flush logic in their class.