Skip to content

Commit

Permalink
Changed module structure and renamed files to compensate for f# bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rommsen committed Sep 13, 2018
1 parent 43ec729 commit 5cfa682
Show file tree
Hide file tree
Showing 36 changed files with 742 additions and 669 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
obj
bin
packages
packages
.vs
47 changes: 24 additions & 23 deletions EventSourcing_DIY.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Step1/Infrastructure.fs" />
<Compile Include="Step1/Domain.fs" />
<Compile Include="Step1/Program.fs" />
<Compile Include="Step2/Infrastructure.fs" />
<Compile Include="Step2/Domain.fs" />
<Compile Include="Step2/Program.fs" />
<Compile Include="Step3/Infrastructure.fs" />
<Compile Include="Step3/Domain.fs" />
<Compile Include="Step3/Program.fs" />
<Compile Include="Step4/Infrastructure.fs" />
<Compile Include="Step4/Domain.fs" />
<Compile Include="Step4/Program.fs" />
<Compile Include="Step5/Infrastructure.fs" />
<Compile Include="Step5/Domain.fs" />
<Compile Include="Step5/Program.fs" />
<Compile Include="Step6/Infrastructure.fs" />
<Compile Include="Step5/Tests.fs" />
<Compile Include="Step6/Domain.fs" />
<Compile Include="Step6/Program.fs" />
<Compile Include="Step6/Tests.fs" />
<Compile Include="Step7/Infrastructure.fs" />
<Compile Include="Step7/Domain.fs" />
<Compile Include="Step7/Program.fs" />
<Compile Include="Step1/Infrastructure1.fs" />
<Compile Include="Step1/Domain1.fs" />
<Compile Include="Step1/Program1.fs" />
<Compile Include="Step2/Infrastructure2.fs" />
<Compile Include="Step2/Domain2.fs" />
<Compile Include="Step2/Program2.fs" />
<Compile Include="Step3/Infrastructure3.fs" />
<Compile Include="Step3/Domain3.fs" />
<Compile Include="Step3/Program3.fs" />
<Compile Include="Step4/Infrastructure4.fs" />
<Compile Include="Step4/Domain4.fs" />
<Compile Include="Step4/Program4.fs" />
<Compile Include="Step5/Infrastructure5.fs" />
<Compile Include="Step5/Domain5.fs" />
<Compile Include="Step5/Program5.fs" />
<Compile Include="Step6/Infrastructure6.fs" />
<Compile Include="Step5/Tests5.fs" />
<Compile Include="Step6/Domain6.fs" />
<Compile Include="Step6/Program6.fs" />
<Compile Include="Step6/Tests6.fs" />
<Compile Include="Step7/Infrastructure7.fs" />
<Compile Include="Step7/Domain7.fs" />
<Compile Include="Step7/Program7.fs" />
<Compile Include="Step7/Tests7.fs" />
<Compile Include="Brainstorming/Infrastructure.fs" />
<Compile Include="Brainstorming/Domain.fs" />
<Compile Include="UI/Menu.fs" />
Expand Down
1 change: 0 additions & 1 deletion Program.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open UI
open UI.Helper
open System
open Expecto


Expand Down
2 changes: 1 addition & 1 deletion Step1/Domain.fs → Step1/Domain1.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Step1.Domain
namespace Step1.Domain

type Flavour =
| Vanilla
Expand Down
3 changes: 2 additions & 1 deletion Step1/Infrastructure.fs → Step1/Infrastructure1.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Step1.Infrastructure
namespace Step1.Infrastructure

type Events<'Event> =
'Event list
Expand All @@ -11,6 +11,7 @@ type EventStore<'Event> =


module EventStore =

type Msg<'Event> =
| Get of AsyncReplyChannel<'Event list>
| Append of Events<'Event>
Expand Down
53 changes: 0 additions & 53 deletions Step1/Program.fs

This file was deleted.

55 changes: 55 additions & 0 deletions Step1/Program1.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
namespace Step1

module Program =

open Step1.Domain
open Step1.Infrastructure


type Msg =
| Append_Flavour_sold_Vanilla
| Append_Flavour_sold_Strawberry
| Append_Flavour_sold_StrawberryFlavourEmptyStrawberry
| GetEvents of AsyncReplyChannel<Event list>

let mailbox () =
let eventStore : EventStore<Event> = EventStore.initialize()

MailboxProcessor.Start(fun inbox ->
let rec loop eventStore =
async {
let! msg = inbox.Receive()

match msg with
| Append_Flavour_sold_Vanilla ->
eventStore.Append [Flavour_sold Vanilla]
return! loop eventStore

| Append_Flavour_sold_Strawberry ->
eventStore.Append [Flavour_sold Strawberry ]
return! loop eventStore

| Append_Flavour_sold_StrawberryFlavourEmptyStrawberry ->
eventStore.Append [Flavour_sold Strawberry ; Flavour_empty Strawberry]
return! loop eventStore

| GetEvents reply ->
reply.Reply (eventStore.Get())
return! loop eventStore
}

loop eventStore
)


let Append_Flavour_sold_Vanilla (mailbox : MailboxProcessor<Msg>) =
mailbox.Post Msg.Append_Flavour_sold_Vanilla

let Append_Flavour_sold_Strawberry (mailbox : MailboxProcessor<Msg>) =
mailbox.Post Msg.Append_Flavour_sold_Strawberry

let Append_Flavour_sold_StrawberryFlavourEmptyStrawberry (mailbox : MailboxProcessor<Msg>) =
mailbox.Post Msg.Append_Flavour_sold_StrawberryFlavourEmptyStrawberry

let getEvents (mailbox : MailboxProcessor<Msg>) =
mailbox.PostAndReply Msg.GetEvents
2 changes: 1 addition & 1 deletion Step2/Domain.fs → Step2/Domain2.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Step2.Domain
namespace Step2.Domain

type Flavour =
| Vanilla
Expand Down
2 changes: 1 addition & 1 deletion Step2/Infrastructure.fs → Step2/Infrastructure2.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Step2.Infrastructure
namespace Step2.Infrastructure

type Events<'Event> =
'Event list
Expand Down
65 changes: 0 additions & 65 deletions Step2/Program.fs

This file was deleted.

67 changes: 67 additions & 0 deletions Step2/Program2.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
namespace Step2

module Program =

open Step2.Domain
open Step2.Infrastructure

let eventStore : EventStore<Event> = EventStore.initialize()

type Msg =
| Append_Flavour_sold_Vanilla
| Append_Flavour_sold_Strawberry
| Append_Flavour_sold_StrawberryFlavourEmptyStrawberry
| GetEvents of AsyncReplyChannel<Event list>
| SoldIcecreams of AsyncReplyChannel<Flavour list>

let mailbox () =
let eventStore : EventStore<Event> = EventStore.initialize()

MailboxProcessor.Start(fun inbox ->
let rec loop eventStore =
async {
let! msg = inbox.Receive()

match msg with
| Append_Flavour_sold_Vanilla ->
eventStore.Append [Flavour_sold Vanilla]
return! loop eventStore

| Append_Flavour_sold_Strawberry ->
eventStore.Append [Flavour_sold Strawberry ]
return! loop eventStore

| Append_Flavour_sold_StrawberryFlavourEmptyStrawberry ->
eventStore.Append [Flavour_sold Strawberry ; Flavour_empty Strawberry]
return! loop eventStore

| GetEvents reply ->
reply.Reply (eventStore.Get())
return! loop eventStore

| SoldIcecreams reply ->
eventStore.Get()
|> List.fold Projections.soldIcecreams.Update Projections.soldIcecreams.Init
|> reply.Reply

return! loop eventStore
}

loop eventStore
)


let Append_Flavour_sold_Vanilla (mailbox : MailboxProcessor<Msg>) =
mailbox.Post Msg.Append_Flavour_sold_Vanilla

let Append_Flavour_sold_Strawberry (mailbox : MailboxProcessor<Msg>) =
mailbox.Post Msg.Append_Flavour_sold_Strawberry

let Append_Flavour_sold_StrawberryFlavourEmptyStrawberry (mailbox : MailboxProcessor<Msg>) =
mailbox.Post Msg.Append_Flavour_sold_StrawberryFlavourEmptyStrawberry

let getEvents (mailbox : MailboxProcessor<Msg>) =
mailbox.PostAndReply Msg.GetEvents

let listOfSoldFlavours (mailbox : MailboxProcessor<Msg>) =
mailbox.PostAndReply Msg.SoldIcecreams
2 changes: 1 addition & 1 deletion Step3/Domain.fs → Step3/Domain3.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Step3.Domain
namespace Step3.Domain

type Flavour =
| Vanilla
Expand Down
File renamed without changes.
Loading

0 comments on commit 5cfa682

Please sign in to comment.