Last active
March 25, 2026 08:06
-
-
Save object/64468455bb861e3cb4d90831529c6cdd to your computer and use it in GitHub Desktop.
Counter actor (stateful)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let counterActor (mailbox: Actor<_>) = | |
| let rec loop lastTime countTotal countMigrated countFailed = | |
| actor { | |
| let! event = mailbox.Receive() | |
| let countTotal = countTotal+1 | |
| return! | |
| match event with | |
| | Increment.Total currentId -> | |
| if countTotal % 1000 = 0 then | |
| // Omitted debug print to console | |
| loop DateTime.Now countTotal countMigrated countFailed | |
| else | |
| loop lastTime countTotal countMigrated countFailed | |
| | Increment.Migrated -> | |
| loop lastTime countTotal (countMigrated+1) countFailed | |
| | Increment.Failed -> | |
| loop lastTime countTotal countMigrated (countFailed+1) | |
| } | |
| loop DateTime.Now 0 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment