forestphoenix / EventSpring

Eventsourcing for Haskell, done slightly differently.
MIT License
0 stars 0 forks source link

[Concept] Serialization to/from a file #2

Closed forestphoenix closed 5 years ago

forestphoenix commented 5 years ago

Serialize the Event to and from a flat file.

Unresolved Issues:

With the current design, deserialization is done via a type class. Is this still a valid design?

Could there be alternatives? How do other eventstores deal with the problem?

forestphoenix commented 5 years ago

Solution: Function StoredType -> (ByteString -> AnsSerialized) is passed to the deserialization

This function can be generated from a Projector for all its events and projections. deserialiseEvents :: Projector a -> (StoredType -> (ByteString -> AnsSerialized)) deserialiseProjections :: Projector a -> (StoredType -> (ByteString -> AnsSerialized)) deserialiseProjIds :: Projector a -> (StoredType -> (ByteString -> AnsSerialized))

forestphoenix commented 5 years ago

For now, only the events will be stored in a flat file.

The layout for the Storage is as follows:

(1-byte version)
(n times:)
  (4-byte length)
  (n-byte event)
  (4-byte crc of length and event)
forestphoenix commented 5 years ago

For now, there are no open questions any more here.