nexiahome/event_store — pull request #25 by james-barnard (2014-10-01 01:00:55+00:00)
Title: 78876656 refactor snapshot

Purpose:
This PR primarily changes the way we store snapshots in redis. Before this PR, we used fully_qualified_name to capture in redis a copy of the last event applied to each stat. This scheme failed to recognize that there are events that occur in each zone and these events were getting lost in a 'last one in wins' scenario. To resolve this, we are now using a compound key made up of `fully_qualified_name` and `sub_key`. `sub_key` is the column name in the event_store to which we are assigning the value `zone_id`.

To accomplish this, I refactored `aggregate` and `event_appender` into `aggregate`, `snapshot`, and `event_stream` which made the actual compound key implementation almost trivial.

Note! This PR will most certainly break faceplate so deploying this code will require a coordinated deploy of faceplate. The change required from faceplate is assigning zone_id to the EventStore::Event struct prior to appending.