Skip to content

Commit

Permalink
Added README for versioning samples
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Dec 5, 2021
1 parent b6f1565 commit 4b8d216
Show file tree
Hide file tree
Showing 8 changed files with 373 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Sample/EventPipelines/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Event Pipelines](./EventPipelines)
# Event Pipelines

Shows how to compose event handlers in the processing pipelines to:
- filter events,
Expand Down
2 changes: 1 addition & 1 deletion Sample/EventStoreDB/Simple/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simple, practical EventSourcing with EventStoreDB and EntityFramework

The PR is adding a new sample that contains the simple Event Sourcing setup with EventStoreDB. For the Read Model, Postgres and Entity Framework are used.
The is the simple Event Sourcing setup with EventStoreDB. For the Read Model, Postgres and Entity Framework are used.

You can watch the webinar on YouTube where I'm explaining the details of the implementation:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ public record ShoppingCartInitialized(
Client Client
);

public static V1.ShoppingCartInitialized Downcast(
ShoppingCartInitialized newEvent
)
{
return new V1.ShoppingCartInitialized(
newEvent.ShoppingCartId,
newEvent.Client.Id
);
}
public static V1.ShoppingCartInitialized Downcast(
ShoppingCartInitialized newEvent
)
{
return new V1.ShoppingCartInitialized(
newEvent.ShoppingCartId,
newEvent.Client.Id
);
}

public static V1.ShoppingCartInitialized Downcast(
string newEventJson
)
{
var newEvent = JsonDocument.Parse(newEventJson).RootElement;
public static V1.ShoppingCartInitialized Downcast(
string newEventJson
)
{
var newEvent = JsonDocument.Parse(newEventJson).RootElement;

return new V1.ShoppingCartInitialized(
newEvent.GetProperty("ShoppingCartId").GetGuid(),
newEvent.GetProperty("Client").GetProperty("Id").GetGuid()
);
}
return new V1.ShoppingCartInitialized(
newEvent.GetProperty("ShoppingCartId").GetGuid(),
newEvent.GetProperty("Client").GetProperty("Id").GetGuid()
);
}

[Fact]
public void UpcastObjects_Should_BeForwardCompatible()
Expand Down Expand Up @@ -74,4 +74,4 @@ public void UpcastJson_Should_BeForwardCompatible()
@event.ShoppingCartId.Should().Be(newEvent.ShoppingCartId);
@event.ClientId.Should().Be(newEvent.Client.Id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ public EventTypeMapping Register<TEvent>(params string[] typeNames)

public class EventSerializer
{
private readonly EventTypeMapping mapping;
private readonly EventTransformations transformations;
private readonly EventTypeMapping mapping;
private readonly EventTransformations transformations;

public EventSerializer(EventTypeMapping mapping, EventTransformations transformations)
{
this.mapping = mapping;
this.transformations = transformations;
}
public EventSerializer(EventTypeMapping mapping, EventTransformations transformations)
{
this.mapping = mapping;
this.transformations = transformations;
}

public object? Deserialize(string eventTypeName, string json) =>
transformations.TryTransform(eventTypeName, json, out var transformed)
? transformed : JsonSerializer.Deserialize(json, mapping.Map(eventTypeName));
public object? Deserialize(string eventTypeName, string json) =>
transformations.TryTransform(eventTypeName, json, out var transformed)
? transformed : JsonSerializer.Deserialize(json, mapping.Map(eventTypeName));
}

[Fact]
Expand Down Expand Up @@ -198,4 +198,4 @@ public void UpcastObjects_Should_BeForwardCompatible()
deserializedEvents[2].Client.Should().Be(eventV3.Client);
deserializedEvents[2].Status.Should().Be(eventV3.Status);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,4 @@ public void UpcastObjects_Should_BeForwardCompatible()
deserializedEvents[2].As<V1.ShoppingCartConfirmed>()
.ShoppingCartId.Should().Be(shoppingCardId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ public void UpcastJson_Should_BeForwardCompatible()
@event.Client.Id.Should().Be(oldEvent.ClientId);
@event.Client.Name.Should().Be("Unknown");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ public void UpcastJson_Should_BeForwardCompatible()
@event.ClientId.Should().Be(oldEvent.ClientId);
@event.InitializedBy.Should().Be(eventMetadata.UserId);
}
}
}

0 comments on commit 4b8d216

Please sign in to comment.