Guidance and Best Practices :)

Hi Guys,

As far as I see from code examples events should implement the Event interface.

The Event interface has Data and Metadata members.

What in your mind would be the best practice of using the Event interface:

  1. Having every event in the system implement this interface (perhaps through the base class).
    Does it mean that events should “know” how to serialize themselves into these two byte arrays?
  2. Having a “wrapping” message implementing Event and wrap/unwrap events when appending/reading from the Event Store?
    Cheers,

Alexey.

I would not have your events implement the event interface.ninstead I would use an adapter that created something the form that the es understands. The place to do this is just before writing them to the store (often there is context info you want as well such as which user did this action).

Make sense?

From the C# client example, it looks like client code is responsible for serializing the event data into bytes?

The caller does serialization etc yes. As far as the API is concerned an event is made up of byte arrays.

Generally we would recommend using json for most scenarios but binary is also valid

We expect that your app would write say 20 lines of code over the top to handle serialization. We should make it return a data object instead of interface to make that more clear

Btw some background on that decision.nthere are many different ways to express this in your model and supporting all of them would be a nightmare of an API. There are some opportunities here for various micro frameworks on top that make opinions…

I wondered, b/c implementing serialization/deserialization as part of integration isn’t the sexiest thing. I assume for the REST API, you are taking the JSON string and just encoding it to bytes. (Couldn’t quite locate the code on github.) Why not default to JSON serialization for the C# API, but offer the lower level also? It’s not a big deal to write 20 LOC, but if most people are going to write the same 20 lines to be compatible with the REST API… :slight_smile:

I think e code will look very different from place to place. What metadata do you store with events? Which serializer to use? By the time a generic library over the top is written it can actually get fairly complex as a generic library.

Also the http interface does json or XML … You can even post XML and get it back as json or vice versa…

The code for this stuff can be found by going throu the atomcontroller located near http service in core.

Cheers,

Greg