Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Feb 13, 2020
1 parent 2364d19 commit 43b3019
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion equinox-fc/Domain/Domain.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Compile Include="InventorySeries.fs" />
<Compile Include="InventoryEpoch.fs" />
<Compile Include="Inventory.fs" />
<!-- <Compile Include="InventoryTransaction.fs" />-->
<Compile Include="InventoryTransaction.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Equinox.Cosmos" Version="2.0.0-rc9" />
Expand Down
26 changes: 15 additions & 11 deletions equinox-fc/Domain/InventoryTransaction.fs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/// Process Manager used to:
/// - Coordinate competing attempts to transfer quantities from stock; if balance is 3 one of contesting requests to remove 2 or 3 items must reach `Failed`
/// - maintain rolling balance of stock levels per Location
/// - while recording any transfers or adjustment in an overall Inventory record
/// The Process is driven by two actors:
/// 1) The 'happy path', where a given actor is executing the known steps of the command flow
/// In the normal case, such an actor will bring the flow to a terminal state (Completed or Failed)
/// 2) A watchdog-projector, which reacts to observed events in this Category by stepping in to complete in-flight requests that have stalled
/// This represents the case where a 'happy path' actor died, or experienced another impediment on the path.
module Fc.InventoryTransaction

open System
Expand All @@ -6,14 +15,13 @@ open System
[<RequireQualifiedAccess>]
module Events =

let [<Literal>] CategoryId = "Transfer"
let (|For|) (inventoryId, transactionId) =
FsCodec.StreamName.compose CategoryId [InventoryId.toString inventoryId; InventoryTransactionId.toString transactionId]
let [<Literal>] CategoryId = "InventoryTransfer"
let (|For|) (inventoryId, transactionId) = FsCodec.StreamName.create CategoryId (InventoryTransactionId.toString transactionId)

type AdjustmentRequested = { location : LocationId; quantity : int }
type TransferRequested = { source : LocationId; destination : LocationId; quantity : int }
type Removed = { balance : int }
type Added = { balance : int }
type AdjustmentRequested = { location : LocationId; quantity : int }

type Event =
| AdjustmentRequested of AdjustmentRequested
Expand Down Expand Up @@ -59,13 +67,9 @@ module Fold =
| Events.Completed -> Completed
let fold : State -> Events.Event seq -> State = Seq.fold evolve

type Result =
{ /// Indicates whether this epoch is closed (either previously or as a side-effect this time)
isClosed : bool
/// Count of items added to this epoch. May be less than requested due to removal of duplicates and/or rejected items
added : int
/// residual items that [are not duplicates and] were not accepted into this epoch
rejected : Events.Event list }
type Command =
| Adjust of Events.AdjustmentRequested
| Transfer of Events.TransferRequested

let decideSync capacity requested (state : Fold.State) : Result * Events.Event list =
let isFresh = function
Expand Down

0 comments on commit 43b3019

Please sign in to comment.