Last active
May 18, 2019 01:23
-
-
Save cgillum/aaa9dbd975a5084edebc06741c153427 to your computer and use it in GitHub Desktop.
Example of "counter" entity in Durable Functions.
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
public static async Task Counter( | |
[EntityTrigger] IDurableEntityContext ctx) | |
{ | |
int currentValue = ctx.GetState<int>(); | |
switch (ctx.OperationName) | |
{ | |
case "add": | |
int amount = ctx.GetInput<int>(); | |
currentValue += amount; | |
break; | |
case "reset": | |
currentValue = 0; | |
break; | |
case "get": | |
ctx.Return(currentValue); | |
return; | |
} | |
ctx.SetState(currentValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment