Add some examples on how to use validate/build events

Closes #277
Refactor retry event logic.

Added documentation and example explaining how to implement custom
retry events.